
/**
 * 
 */
function HandWrite(params){
	this.setOptions(params);
};


HandWrite.prototype.setOptions = function(params) {

	this.fileType = params.fileType;// 文档类型
	this.webRoot = params.webRoot;
	this.fileId = params.fileId;
	this.contentId = params.fileId;

	this.currentLanguage = params.currentLanguage;
	this.createDate = params.createDate;
	this.originalCreateDate = "";// params.originalCreateDate;
	this.originalFileId = params.originalFileId;// 原始文件类型
	this.needCloneFile = "";// params.needCloneFile;
	this.needReadFile = params.needReadFile;
	this.userId = params.handWriteCurrentUserId;
	this.currentUserName = params.currentUserName;
	this.affairMemberId = params.affairMemberId;
	this.affairMemberName = params.affairMemberName;
	this.officeFileRealSize = params.officeFileRealSize;
	this.officeOcxUploadMax = params.officeOcxUploadMax;
	this.officecanPrint = params.officecanPrint; // 是否可以打印
	this.officecanSaveLocal = params.officecanSaveLocal;// 是否可以保存到本地
	this.hasPDF417Manager = params.hasPDF417Manager;// 是否有二维码插件
	this.isFromRegsitPendingList = params.isFromRegsitPendingList;// 是否是登记，并且是从待登记列表中进来的。
	this.isNewEdocPage = params.isNewEdocPage;// 是否来自公文新建页面
	this.isFromTemplateOfNewEdocPage = params.isFromTemplateOfNewEdocPage;// 拟文是否调用模板
	this.isTemplete = params.isTemplete;// 是否是模板制作页面
	this.isNewCollPage = params.isNewCollPage;// 判断当前页面是否是协同新建
	this.isNewInfoPage = params.isNewInfoPage;// 判断当前页面是否是信息新建
	if (!this.isNewInfoPage) {
		if (parent.isNewInfoPage) {
			this.isNewInfoPage = parent.isNewInfoPage;
		} else if (parent.parent.isNewInfoPage) {
			this.isNewInfoPage = parent.parent.isNewInfoPage;
		}
	}
	this.hasAdvanceOcx = params.hasAdvanceOcx;// 是否为高级office控件
	this.isNewOfficeFilePage = params.isNewOfficeFilePage;// 是否是新建页面
	this.isLoadOfficeImmediate = params.isLoadOfficeImmediate;
	this.canEditContent = params.canEditContent;// 是否可以修改正文
	this.canTaohong = params.canTaohong;// 是否可以进行套红（表单套红）
	this.formDataId = params.formDataId;
	this.privateId = params.privateId;
	this.currentPage = params.currentPage;
	this.showHl = params.showHl;
	this.actionCanSign = params.actionCanSign;
	this.isRemoveTrace = params.isRemoveTrace;//保存本地时是否强制清除痕迹
	/**
	 * 第一位 “0” 只读、且不能拷贝， “1” 起草编辑[可写无痕迹保留]， “2” 编辑[有痕迹保留，不可以修订]， “3” 审核[有修订菜单]，
	 * “4” 只读、可以复制文档内容。 第二位 0不可手写批注，1可以手写批注。
	 */
	this.editType = params.editType;
	this.canEdit = params.canEdit; // 是否能够编辑
	this.canWrite = params.canWrite;// 是否可以进行手写批注
	this.hasTrail = params.hasTrail; // 是否显示保留痕迹
	this.isSaveModifyMark = params.isSaveModifyMark;
	this.setSignatureBlack = params.setSignatureBlack;// 是否设置印章为灰色
	this.initOfficeSucessCallback = params.initOfficeSucessCallback;// 表单套红判断正文是否加载完成的回调
	this.initOfficeErrorCallback = params.initOfficeErrorCallback;
	this.initOfficeCloseCallback = params.initOfficeCloseCallback;
	this.callback = params.callback;
	this.originalNeedClone = params.originalNeedClone;
	this.needSave = params.needSave;
	this.isFullSize = params.isFullSize;
	this.extendParams = params.extendParams;
	this.saveLocalFileName = params.saveLocalFileName;
	this.sessionId = params.sessionId;
	this.isPrint = params.isPrint;
	// ======================================HandWrite外部传入的参数
	// 结束====================================================

	// ======================================HandWrite内部使用的参数
	// 开始====================================================
	this.wordTextContent = "";// 保存word的文字内容,盖章后可以移动印章,修改文字,保存的时候判断文字是否被修改,如果修改了禁止保存;
	this.curDataID = "";// 记录当前版本对应数据的ID
	this.curMenuID = 0;// 记录当前版本菜单ID,用于菜单变灰控制
	this.curMenuEditType = "";// 记录当前版本的编辑模式,用于控制菜单
	this.backupIds = "";// 记录备份文件id
	this.isLoadOfficeFile = true;// 是否需要load Office正文
	this.isSignOperation = false;// 是否是签章操作的状态，即页面上执行了签章操作。如果执行了签章操作，即为修改状态。

	// 系统参数，是否保存痕迹
	this.isRetainedTraces = typeof (params.isRetainedTraces) != "undefined" ? params.isRetainedTraces
			: false;
	this.isShowHualian = false; // 是否显示花脸
	this.canCopy = 1; // 是否能够复制
	this.subjectValue = ""// 获取到的标题
	this.reWrite = false;// 文档掉入之后，是否进行过重新批注
	this.isShowShenYueMenu = true; // 是否显示审阅菜单
	this.isToPdf = false; // 是否转换成pdf
	this.newPdfId;// 新生成的pdfid
	this.page_OcxState = "";// office控件是否加载完成
	this.loadBackFile = false;
	this.loadOfficeSuccess = false;
	this.contentUpdate = false;

	this.updateOcx = false;
	this.isSave = false;
}




HandWrite.prototype.checkOcxOnReady = function(){
	return isOcxReady ;
}

HandWrite.prototype.setSubjectValue = function(subjectValue){
	this.subjectvalue = subjectValue;
}
HandWrite.prototype.setEditType = function(editType){
  this.editType=editType;
}

HandWrite.prototype.setAffairMemberId = function(affairMemberId){
	  this.affairMemberId=affairMemberId;
}
HandWrite.prototype.setAffairMemberName = function(affairMemberName){
	this.affairMemberName=affairMemberName;
}
HandWrite.prototype.setFileId = function(fileId){
	this.fileId=fileId;
}
HandWrite.prototype.setFormDataId = function(formDataId){
	this.formDataId=formDataId;
}
HandWrite.prototype.setOriginalFileId = function(originalFileId){
	this.originalFileId=originalFileId;
}
HandWrite.prototype.setOriginalCreateDate = function(originalCreateDate){
	this.originalCreateDate=originalCreateDate;
}
HandWrite.prototype.setCreateDate = function(createDate){
	this.createDate=createDate;
}
HandWrite.prototype.getContentUpdate = function(){
	return this.contentUpdate;
}

//判断是否进行签章
HandWrite.prototype.getIsSignOperation = function(){
	return this.isSignOperation;
}
HandWrite.prototype.setIsSignOperation = function(isSignOperation){
	this.isSignOperation=isSignOperation;
}
//----------------弹出模态对话框禁止使用insert菜单--------------------------
//作用：控制OFFICE菜单

//是否需要仅用insert菜单,只有xls在弹出模态窗口中才禁止
function WebOfficeInsertMenuDisable(ocxObj,DisableMenu){
	var disableInsertMenu=null;
	if(disableInsertMenu==null){
  		if(ocxObj.FileType==".xls" && top.dialogArguments!=null){
  			disableInsertMenu=true;
  		}else{
  			disableInsertMenu=false;
  		}
	}	
	if(disableInsertMenu==false){
		return;
	}
  if (DisableMenu){
      //OFFICE2000-2003的插入菜单禁止
      ocxObj.DisableMenu("插入(&I)");  //禁止"插入"菜单 
      
      //OFFICE2007的插入菜单隐藏
      ocxObj.RibbonUIXML = '' +
      '<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">' +
      '  <ribbon startFromScratch="false">'+                    //不显示所有选项卡控制 false显示选项卡；true不显示选项卡
      '    <tabs>'+
      '      <tab idMso="TabInsert" visible="false">' +         //关闭插入工具栏
      '      </tab>'+
      '    </tabs>' +
      '  </ribbon>' +
      '</customUI>';
  }else{
      //OFFICE2000-2003的插入菜单显示
      ocxObj.EnableMenu("插入(&I)");  //显示"插入"菜单
  }
}
//------------------------------结束------------------------------

//文档是否已修改
HandWrite.prototype.bodyIsModified = function(){
	try{
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		var _editType = ocxObj.EditType;
		var type = _editType.charAt(0);
		if(type == "1" || type == "2"){
			return true;
		}
		return false;
	}catch(e){
		return false;
	}
	
}
HandWrite.prototype.updateOfficeState=function(state){
  var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
  ocxObj.EditType = state;
  this.editType=state;
}
//删除office正文中的痕迹，并且保存office正文
HandWrite.prototype.removeTrail=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	//关闭痕迹
	ocxObj.EditType="1,0"; 
	//清除痕迹,需要try catch.Excel正文转发会报js错误。
	try{
		ocxObj.ClearRevisions();
		//提供花脸查看功能
		ocxObj.WebSetMsgByName("editType","clearDocument");
	}catch(e){} 

}
//新建公文模板的时候：删除office正文中的痕迹，并且保存office正文，不保存EDOC_BODY对象。
HandWrite.prototype.removeTrailAndSaveWhenTemplate=function(){
	
	//先判断控件是否可用
	if(!this.isHandWriteRef()){
		return;
	}
	//需要先打开正文才能清除痕迹。
	this.checkOpenState();
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	//关闭痕迹
	ocxObj.EditType="1,0"; 
	//清除痕迹
	try{
		ocxObj.ClearRevisions();
	}catch(e){}
	//提供花脸查看功能
	ocxObj.WebSetMsgByName("editType","clearDocument");
	//保存正文
	this.contentUpdate=true;
	//parent.checkExistBody();
	if(parent.saveOffice()==false){
      return false;
    }
    return true;
}
//拟文的时候：删除office正文中的痕迹，并且保存office正文
HandWrite.prototype.removeTrailAndSaveWhenDraft=function(){
	//先判断控件是否可用
	if(!this.isHandWriteRef()){
		return;
	}
	//需要先打开正文才能清除痕迹。
	if(!this.contentUpdate){
		this.checkOpenState();
	}
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	//关闭痕迹
	ocxObj.EditType="1,0"; 
	//清除痕迹
	ocxObj.ClearRevisions();
	//提供花脸查看功能
	ocxObj.WebSetMsgByName("editType","clearDocument");
	//保存正文
	this.contentUpdate=true;
	parent.checkExistBody();
	if(parent.saveOffice()==false) {
      return false;
    }
    parent.draftTaoHong="draftTaoHong";
    return true;
}


HandWrite.prototype.checkOpenState=function(){
	if(this.isLoadOfficeFile==false){
		this._loadOffice();
		this.isLoadOfficeFile=true;
	}
	//refreshOfficeLable();
}

//刷新Office中文中的Label.
HandWrite.prototype.refreshOfficeLable=function(sendForm,opinionArr){
	//刷新套红后正文中的标签。需要先将OFFICE控件设置为可编辑模式。
	if(sendForm){
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		if(ocxObj.EditType=="0,0"||ocxObj.EditType=="4,0"){
			var srcEditType=ocxObj.EditType;
			ocxObj.EditType="1,0";
			setAllLable(sendForm,"edoc",parent.extendArray,opinionArr);
			ocxObj.EditType=srcEditType;
		}else{
			setAllLable(sendForm,"edoc",parent.extendArray,opinionArr);
		}
	}
}
//得到正文中书签的个数，可以根据此来判断正文是否已经进行了套红操作。
HandWrite.prototype.getBookmarksCount=function(){
	this.checkOpenState();
	var mCount=0;
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	try{
	 	mCount = ocxObj.WebObject.Bookmarks.Count;
	}catch(e){}
	return mCount;
}
HandWrite.prototype.checkNeedSave=function(){	
	var ret=true;	
	if(this.isLoadOfficeFile==true){
		return true;
	}
	if(this.isNewOfficeFilePage==true){
		//新建页面
	    this._loadOffice();
		this.isLoadOfficeFile=true;
		ret=true;
		
	}else{
	  //中间office处理修改页面
	  if(this.isLoadOfficeFile==true){
		  ret=true;
	  }else {
		  ret=false;
	  }
	}	
	return ret;
}
HandWrite.prototype.isLoadOffice=function(){
	if(this.page_OcxState == "complete"){
		return true;
	}
	return false;
}
HandWrite.prototype.isLoadOfficeSuccess=function(){
	return this.loadOfficeSuccess;
}
/**
 * 审阅菜单的设置策略：
 *  2003受WebSetRevision接口的控制。
 *  2007 & 2010 用如下 RibbonUIXML 的方式控制。
 * @param WebOffice
 */
//设置OFFICE2007的选项卡显示
function WebSetRibbonUIXML(WebOffice){
	try{ 
		WebOffice.RibbonUIXML = '' +
		  '<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui">' +
		  '  <ribbon startFromScratch="false">'+                    //不显示所有选项卡控制 false显示选项卡；true不显示选项卡
		  '    <tabs>'+
		  '      <tab idMso="TabReviewWord" visible="true">' +     //关闭审阅工具栏
		  '      </tab>'+
		  '    </tabs>' +
		  '  </ribbon>' +
		  '</customUI>';
	}catch(e){
		
	}
}

function getCurrentUserName(){
	var _currUserName = "";
	
	if(typeof(getA8Top)=="function" 
		&& typeof(getA8Top().$)!='undefined'
		&& typeof(getA8Top().$.ctx)!='undefined'
	    && typeof(getA8Top().$.ctx.CurrentUser)!='undefined'){
		
		_currUserName = getA8Top().$.ctx.CurrentUser.name;
		
	}else if(typeof(getCtpTop)=="function" 
		&& typeof(getCtpTop().$)!='undefined' 
		&& typeof(getCtpTop().$.ctx)!='undefined' 
	    && typeof(getA8Top().$.ctx.CurrentUser)!='undefined'){
		
		_currUserName = getCtpTop().$.ctx.CurrentUser.name;
		
	}else{
		_currUserName =  parent.currUserName;
	}
	return _currUserName;
}


/**
 * 设置客户端本地OFFICE，显示图片，否则印章图片可能显示不出来。
 * @param ocxObj
 * @param state
 */
function setOfficeShowPicture(ocxObj,state){
	try{
		ocxObj.WebObject.Application.ActiveWindow.View.ShowDrawings = state;
	}catch(e){
		
	}
}
/**
 * 显示或隐藏工具栏，重新设置一下工具栏状态，避免出现Excel的正文隐藏前几行的问题
 */
function resetToolBar(ocxObj){
	  try{
	    var mApp = ocxObj.WebObject.Application;
	    //显示或隐藏工具栏
	    if(ocxObj.FileType == ".xls"){
	      if(mApp.ExecuteExcel4Macro('Get.ToolBar(7,"Ribbon")')){
	        mApp.ExecuteExcel4Macro('Show.ToolBar("Ribbon", false)');
	        mApp.ExecuteExcel4Macro('Show.ToolBar("Ribbon", true)');
	      }else{
	        mApp.ExecuteExcel4Macro('Show.ToolBar("Ribbon", true)');
	        mApp.ExecuteExcel4Macro('Show.ToolBar("Ribbon", false)');
	      }
	    }
	  }
	  catch(e){
	  }
}

/**
 * 检查当前文件大小是否超过系统配置大小
 */
function checkFileSize(officeFileRealSize,officeOcxUploadMax, ocxObj){
	try{
		if(typeof(officeFileRealSize)!='undefined'  &&  typeof(officeOcxUploadMax)!='undefined'
			&& officeFileRealSize!='' && typeof(officeOcxUploadMax)!=''){
			if(parseFloat(officeFileRealSize)>parseFloat(officeOcxUploadMax)){
				ocxObj.alert(getOfficeLanguage("alert_err_OcxFileBig_not_open",officeOcxUploadMax));
				return false;
			}
		}
	}catch(e){
		
	}
	return true;
}


/**
 * 设置印章颜色，如果是部门归档的公文，则设置印章为灰色的，其他的情况不变，维持原来文件的颜色
 */
var setSignatureBlack="";
function setSignatureColor(ocxObj){
    if(typeof(handWriteObj.setSignatureBlack) != "undefined"){
         setSignatureBlack = handWriteObj.setSignatureBlack ;
    }
   
    if(setSignatureBlack == 'true'){
        var hasSign=ocxObj.SignatureCount(true)>0 || ocxObj.SignatureCount(false)>0;//是否有合法印章	
    	var isProtect=IsOfficeProtection(ocxObj);
    	if(hasSign){	
    		try{
    			if(isProtect==1)
        		{
        			ocxObj.WebSetProtect(false,"");
        			ocxObj.SignatureColor(false);
            		ocxObj.WebSetProtect(true,"");
        		}else{
        			//保存本地文件前把印章变灰，使印章实效
        			ocxObj.SignatureColor(false);
        		}
    		}catch(e){}
    		
    	}
    }
}


//设置菜单状态，是否可用，不可用的菜单，变灰
HandWrite.prototype.setOcxMenuState=function(ocxObj){
  var ret=false;  
  var isShowShenYueMenu = true; //是否显示审阅菜单
  var canModifyContent = this.canEditContent;
  if(this.editType=="1,0"){//起草
	//ocxObj.DisableMenu("menu_CharPostil,menu_HandWritePostil,menu_ClearTrail,menu_ResetPostil,menu_CheckSeal,menu_SginSeal,menu_HiddenTrail,menu_DisplayTrail,menu_BrowseChar,menu_BrowseHandWrite");
    // test code
	if(!this.loadBackFile){
		ocxObj.DisableMenu(getOfficeLanguage("menu_RepairContent"));
	}
	canModifyContent = "false";
    ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_EditContent,menu_HandWritePostil,menu_ResetPostil,menu_HiddenTrail,menu_BrowseChar,menu_BrowseHandWrite"));
	if(ocxObj.LastType!=2){//最新为文字
		ocxObj.DisableMenu(getOfficeLanguage("menu_ClearTrail"));
		
		if(this.isSaveModifyMark === 'false'){
			ocxObj.WebSetRevision(false,false,false,isShowShenYueMenu);
		}
		else{
			ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);
		}
		
		if(this.currentPage && this.currentPage == "govdocSummary"){
			this.initBackUpMenuState(ocxObj);
		}
	}
  }else if(this.editType=="0,0" ||this.editType=="4,0"){//只读
	if(this.curMenuID==0){
		this.initBackUpMenuState(ocxObj);
	}
	canModifyContent = "false";
    ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_HandWritePostil,menu_ClearTrail,menu_ResetPostil,menu_SginSeal,menu_OpenFile,menu_HiddenTrail,menu_BrowseChar,menu_BrowseHandWrite,menu_PageSet,menu_RepairContent"));
    //只读状态下应该不显示痕迹，先显示痕迹按钮才显示
    ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);
    if(ocxObj.LastType==2){//显示手写批注的时候隐藏痕迹,和印章校验按钮
      ocxObj.DisableMenu(getOfficeLanguage("menu_DisplayTrail,menu_CheckSeal,menu_BrowseHandWrite,menu_SaveFile"));
      ocxObj.EnableMenu(getOfficeLanguage("menu_BrowseChar"));
    }else{//文字最新,添加切换到文字浏览得按钮
      if(ocxObj.Pages>0){
    	  ocxObj.EnableMenu(getOfficeLanguage("menu_BrowseHandWrite"));
      }
      ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));
    }
  }else{
    ocxObj.ShowToolBar="1";
  }
  if(canModifyContent == "true"){
		ocxObj.EnableMenu(getOfficeLanguage("menu_EditContent,menu_OpenFile,menu_ClearTrail"));
  }else{
  		ocxObj.DisableMenu(getOfficeLanguage("menu_EditContent"));
  }
  
  if(this.currentPage && this.currentPage == "govdocSummary" && (this.actionCanSign == "true" || this.actionCanSign == true)){
  	ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
  }
  
  ret=true;
  return ret;
}
//设置菜单状态，是否可用，不可用的菜单，变灰
HandWrite.prototype.setOcxMenuStateBeforeOpen = function(ocxObj){
	  var ret=false;  
	  var canModifyContent = this.canEditContent;
	  if(this.editType=="1,0"){//起草
		if(!this.loadBackFile){
			ocxObj.DisableMenu(getOfficeLanguage("menu_RepairContent"));
		}
		canModifyContent = "false";
	    ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_EditContent,menu_HandWritePostil,menu_ResetPostil,menu_HiddenTrail,menu_BrowseChar,menu_BrowseHandWrite"));
		if(ocxObj.LastType!=2){//最新为文字
			ocxObj.DisableMenu(getOfficeLanguage("menu_ClearTrail"));
		}
	  }else if(this.editType=="0,0" ||this.editType=="4,0"){//只读
		canModifyContent = "false";
	    ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_HandWritePostil,menu_ClearTrail,menu_ResetPostil,menu_SginSeal,menu_OpenFile,menu_HiddenTrail,menu_BrowseChar,menu_BrowseHandWrite,menu_PageSet,menu_RepairContent"));
	    if(ocxObj.LastType==2){//显示手写批注的时候隐藏痕迹,和印章校验按钮
	      ocxObj.DisableMenu(getOfficeLanguage("menu_DisplayTrail,menu_CheckSeal,menu_BrowseHandWrite,menu_SaveFile"));
	      ocxObj.EnableMenu(getOfficeLanguage("menu_BrowseChar"));
	    }else{//文字最新,添加切换到文字浏览得按钮
	      if(ocxObj.Pages>0){
	    	  ocxObj.EnableMenu(getOfficeLanguage("menu_BrowseHandWrite"));
	      }
	      ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));
	    }
	  }else if(this.editType=="2,1"){
		  ocxObj.EnableMenu(getOfficeLanguage("menu_ClearTrail"));
	  }else{
	    ocxObj.ShowToolBar="1";
		ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
	  }
	  if(canModifyContent == "true"){
			ocxObj.EnableMenu(getOfficeLanguage("menu_EditContent"));
	  }else{
	  		ocxObj.DisableMenu(getOfficeLanguage("menu_EditContent"));
	  }
	  
	  if(this.currentPage && this.currentPage == "govdocSummary" && (this.actionCanSign == "true" || this.actionCanSign == true)){
	  	ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
	  }
}
//设置菜单状态，是否可用，不可用的菜单，变灰
HandWrite.prototype.setOcxMenuStateAfterOpen=function(ocxObj){
	var isShowShenYueMenu = true; //是否显示审阅菜单
	var canModifyContent = this.canEditContent;
	if(this.editType=="1,0"){//起草
		canModifyContent = "false";
		if(ocxObj.LastType!=2){//最新为文字
			ocxObj.DisableMenu(getOfficeLanguage("menu_ClearTrail"));
			
			if(this.isSaveModifyMark === 'false'){
				ocxObj.WebSetRevision(false,false,false,isShowShenYueMenu);
			}else{
				ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);
			}
		}
	}else if(this.editType=="0,0" ||this.editType=="4,0"){//只读
		canModifyContent = "false";
		//只读状态下应该不显示痕迹，先显示痕迹按钮才显示
		ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);
	}else{
		ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);
	}
}
/*初始化备份菜单状态*/
HandWrite.prototype.initBackUpMenuState=function(ocxObj){
  this.curDataID=ocxObj.RecordID;
  if(this.curMenuID <200){
	  this.curMenuID=200;
  }
  this.backupIds=ocxObj.WebGetMsgByName("backupIds");
  var ids="";
  var i,mid;
  if(this.backupIds.length<=0){return;}
  ids=this.backupIds.split(",");
  if(ids.length>0){
    for(i=0;i<ids.length;i++){
	mid=201+i;
	if(this.curMenuID==mid){break;}
	ocxObj.EnableMenu(getVerMenuName(mid));
    }
  }
}
var initOcxMenued = false;
HandWrite.prototype.initOcxMenu=function(ocxObj){//工具栏菜单
	try{ 
		initOcxMenued = true;
	    ocxObj.pencolor="#FF0000";
	    ocxObj.penwidth="1";
	    try{ocxObj.Print=true;}catch(e){}
	    
	    if(typeof(this.canTaohong)!="undefined" && this.canTaohong){//协同正文套红
			ocxObj.AppendMenu("1",getOfficeLanguage("menu_OpenFile"),png10);
			ocxObj.AppendMenu("2",getOfficeLanguage("menu_SaveFile"),png2);
			ocxObj.AppendMenu("106",getOfficeLanguage("menu_PageSet"),png28);
			ocxObj.AppendMenu("107",getOfficeLanguage("menu_Print"),png13);
			ocxObj.AppendMenu("109",getOfficeLanguage("menu_EditContent"),png132);
			/*if(ocxObj.FileType==".xls"||ocxObj.FileType==".xlsx"||ocxObj.FileType==".wps"){
				ocxObj.DisableMenu(getOfficeLanguage("menu_PrintPreview"));
			}*/
			ocxObj.AppendMenu("604","-");
			ocxObj.AppendMenu("102",getOfficeLanguage("menu_SaveExit"),png16);
			ocxObj.AppendMenu(getOfficeLanguage("menu_A8Col"),"-");    
			ocxObj.AppendMenu("13",getOfficeLanguage("menu_DisplayTrail"),png26);
			ocxObj.AppendMenu("12",getOfficeLanguage("menu_HiddenTrail"),png29);
			ocxObj.AppendMenu("601","-");
			ocxObj.AppendMenu("11",getOfficeLanguage("menu_SginSeal"),png15);
			ocxObj.AppendMenu("10",getOfficeLanguage("menu_CheckSeal"),png20);
			if(ocxObj.VersionEx()=="menu_TopVer"){
			  ocxObj.AppendMenu("602","-");
			  ocxObj.AppendMenu("14",getOfficeLanguage("menu_BrowseChar"),png42);
			  ocxObj.AppendMenu("15",getOfficeLanguage("menu_BrowseHandWrite"),png41);
			}
			//正文类型是word，并且可以编辑，并且安装金格二维码
			if(this.hasPDF417Manager && typeof this.CopyRight && (ocxObj.FileType == ".doc" || ocxObj.FileType == ".docx")){
				ocxObj.AppendMenu("18",getOfficeLanguage("menu_BarCode"),png140);
				ocxObj.DisableMenu(getOfficeLanguage("menu_BarCode"));
			  }
			   
	    }else{//其它地方套红
			ocxObj.AppendMenu("1",getOfficeLanguage("menu_OpenFile"),png10);
			ocxObj.AppendMenu("2",getOfficeLanguage("menu_SaveFile"),png2);
			ocxObj.AppendMenu("106",getOfficeLanguage("menu_PageSet"),png28);
			ocxObj.AppendMenu("107",getOfficeLanguage("menu_Print"),png13);
			ocxObj.AppendMenu("108",getOfficeLanguage("menu_PrintPreview"),png80);
			ocxObj.AppendMenu("109",getOfficeLanguage("menu_EditContent"),png132);
			/*if(ocxObj.FileType==".xls"||ocxObj.FileType==".xlsx"||ocxObj.FileType==".wps"){
				ocxObj.DisableMenu(getOfficeLanguage("menu_PrintPreview"));
			}*/
			if((ocxObj.EditType!="1,0" || (this.currentPage && this.currentPage == "govdocSummary")) && this.curMenuID==0){//版本菜单在 正常模式,第一次初始化,并且非起草才出现
				if(this.isNewOfficeFilePage!=true && this.showHl!="false"){//新建页面屏蔽花脸
					ocxObj.AppendMenu("603","-");
					var i=0;
					var imgId="";
					for(i=200;i<206;i++){
						if(i==200){
							imgId=png40;
						}else if(i==201){
							imgId=png31;
						}else if(i==202){
							imgId=png32;
						}else if(i==203){
							imgId=png33;
						}else if(i==204){
							imgId=png34;
						}else{
							imgId=png35;
						}
						ocxObj.AppendMenu(i,getVerMenuName(i),imgId);
						ocxObj.DisableMenu(getVerMenuName(i));
					}
				}
			}
			ocxObj.AppendMenu("604","-");
			ocxObj.AppendMenu("102",getOfficeLanguage("menu_SaveExit"),png16);
			ocxObj.AppendMenu(getOfficeLanguage("menu_A8Col"),"-");    
			if(ocxObj.VersionEx()=="Advance"){
			  ocxObj.AppendMenu("3",getOfficeLanguage("menu_CharPostil"),png23);
			  ocxObj.AppendMenu("4",getOfficeLanguage("menu_HandWritePostil"),png24);
			  ocxObj.AppendMenu("6",getOfficeLanguage("menu_ResetPostil"),png30);
			  ocxObj.AppendMenu("600","-");
			}
			
			//if(nodeActorId!=passReadId)
			{
			  ocxObj.AppendMenu("5",getOfficeLanguage("menu_ClearTrail"),png25);
			if(typeof(this.isRemoveTrace)=="undefined"){//屏蔽显示、隐藏痕迹的两个选项
				ocxObj.AppendMenu("13",getOfficeLanguage("menu_DisplayTrail"),png26);
				ocxObj.AppendMenu("12",getOfficeLanguage("menu_HiddenTrail"),png29);
			}
			ocxObj.AppendMenu("601","-");
			  ocxObj.AppendMenu("11",getOfficeLanguage("menu_SginSeal"),png15);
			}
			ocxObj.AppendMenu("10",getOfficeLanguage("menu_CheckSeal"),png20);
			if(ocxObj.VersionEx()=="menu_TopVer"){
			  ocxObj.AppendMenu("602","-");
			  ocxObj.AppendMenu("14",getOfficeLanguage("menu_BrowseChar"),png42);
			  ocxObj.AppendMenu("15",getOfficeLanguage("menu_BrowseHandWrite"),png41);
			}
			//正文类型是word，并且可以编辑，并且安装金格二维码
			if(this.hasPDF417Manager && typeof this.CopyRight && (ocxObj.FileType == ".doc" || ocxObj.FileType == ".docx")){
				ocxObj.AppendMenu("18",getOfficeLanguage("menu_BarCode"),png140);
				ocxObj.DisableMenu(getOfficeLanguage("menu_BarCode"));
			}
	    }
	    ocxObj.AppendMenu(getOfficeLanguage("menu_A8Other"),"-");
		ocxObj.AppendMenu("101",getOfficeLanguage("menu_FullScreenMode"),png22);
		ocxObj.AppendMenu("110",getOfficeLanguage("menu_RepairContent"),png66);
		ocxObj.AppendMenu("100",getOfficeLanguage("menu_OcxVer"),png17);
		
	    if(ocxObj.WindowStatus==1){ocxObj.DisableMenu(getOfficeLanguage("menu_SaveExit"));}
	        ocxObj.DisableMenu("合并文档(&D)...");
	        ocxObj.DisableMenu("保护文档(&P)...");
	        ocxObj.DisableMenu("宏(&M)");
	      //  ocxObj.DisableMenu("选项(&O)...");
	        ocxObj.DisableMenu("书签(&K)...");
	    }catch(ea){}
	    
	}

function getVerMenuName(id){
  if(id==200){
	  return getOfficeLanguage("menu_CurrentVer");
  }else if(id==201){
	  return getOfficeLanguage("menu_Ver1");
  }else if(id==202){
	  return getOfficeLanguage("menu_Ver2");
  }else if(id==203){
	  return getOfficeLanguage("menu_Ver3");
  }else if(id==204){
	  return getOfficeLanguage("menu_Ver4");
  }else if(id==205){
	  return getOfficeLanguage("menu_Ver5");
  }
}

HandWrite.prototype.getVerMenuDataId=function(ocxObj,mid){  
  if(mid==200){
	  return this.curDataID;
  }else{
    return this.backupIds.split(",")[mid-201];
  }
}

function removeOfficeDiv(){
	var o = document.getElementById("officeDivInner");
	if(o){
		o.removeNode(true);
	}
	
	var contentObj = document.getElementById("content");
	if(contentObj){	
		contentObj.value = originContent;
	}
}
/**
 * 将当前文档转化为PDF文档
 * newPdfFileId：新生成的PDF文档的ID.
 */
HandWrite.prototype.transformWordToPdf=function(newPdfFileId){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	try{
		var _states = ocxObj.GetVersionInfo();
		if(_states && _states.substring(2,3)=="0"){
			ocxObj.alert(getOfficeLanguage("alert_NoAdvance_office"));
			return;
		}
	}catch(e){}
	
    if(typeof(newPdfFileId)!="undefined" && newPdfFileId!=""){
        this.newPdfId=newPdfFileId;  
    }else {
        //alert_convertToPdfInvalidArgument:当前文档转化为PDF文档的时候，传入的参数不合法，请重新设置参数
        ocxObj.alert(getOfficeLanguage("alert_convertToPdfInvalidArgument"));
        return false;
    }
    this.isToPdf=true;//当前操作时转化为PDF。
    this.checkOpenState();
    this.delComments();
    var state= this.saveOffice();
    return state;
}
/**
 * 保存office正文
 */
HandWrite.prototype.saveOffice=function(stdOffice) {
	
	if(!this.isHandWriteRef())return;
	var ocxObj = document.getElementById("WebOffice2015");
	ocxObj.Style.ShowOpenProgress = true;
    ocxObj = ocxObj.FuncExtModule;
  //如果是word类型的公文正文不需要转换成标准office正文
    if(!this.isLoadOfficeImmediate){
    	ocxObj.WebSetMsgByName("notJinge2StandardOffice","true");
    }
    if(!this.isToPdf){
    	//如果转PDF操作的话，肯定是要向后台保存的，所以不需要判断是否保存
    	if(this.checkNeedSave()==false){
    		return true;
    	}
    }
	var state=false;
	try{
		ocxObj.AllowEmpty=true;//新版控件内容为空时会有提示，去掉提示
		var hasFormTaoHong = ocxObj.WebGetMsgByName("hasFormTaoHong");
		if(hasFormTaoHong != null && hasFormTaoHong == "1"){
			ocxObj.AllowEmpty=false;
		}
		ocxObj.WebSetProtect(false, "");  //""表示密码为系统默认
  		ocxObj.WebSetMsgByName("CATEGORY", "1");
		if(ocxObj.Version()){
			ocxObj.WebSetMsgByName("clientVer", ocxObj.Version());//客户端控件版本,放置版本和服务器端不一致
		}
		
		/*通过下面这种方式设置的参赛，在经过一次服务交换后会丢失，需要重新设置*/
		if( this.originalFileId){
			ocxObj.WebSetMsgByName("originalFileId", this.originalFileId);
		}
		if( this.originalCreateDate){
			ocxObj.WebSetMsgByName("originalCreateDate", this.originalCreateDate);
		}
		if(this.createDate){
			ocxObj.WebSetMsgByName("CREATEDATE", this.createDate);
		}
		if(this.needCloneFile){
			ocxObj.WebSetMsgByName("needCloneFile", this.needCloneFile);
		}
		if(this.needReadFile){
			ocxObj.WebSetMsgByName("needReadFile", this.needReadFile);
		}
		if(this.draftTaoHong){
			ocxObj.WebSetMsgByName("draftTaoHong",this.draftTaoHong);//是否进行了拟文套红。
		}
		if(this.needInsertToV3XFile){
			ocxObj.WebSetMsgByName("needInsertToV3XFile",this.needInsertToV3XFile);
		}
		if(this.FileType){
			ocxObj.WebSetMsgByName("realFileType",this.FileType);
		}else{
			if(ocxObj.FileType){
				ocxObj.WebSetMsgByName("realFileType",ocxObj.FileType);
			}
		}
		// 是否编辑的上传文档
		if(stdOffice){
			ocxObj.WebSetMsgByName("stdOffice", stdOffice);
		} 
		//没必要每次保存的时候临时到父窗口取ID，当切换的时候会出现问题
		if(this.fileId){
			ocxObj.RecordID = this.fileId;
		}
		if(this._checkSignUpdate(ocxObj)==false){
			return false;
		}
		ocxObj.MaxFileSize=this.officeOcxUploadMax;
		//套红失败，不允许保存
		if(ocxObj.WebGetMsgByName("CUROPERATE")=="TaoHong"){
			ocxObj.alert(getOfficeLanguage("alert_err_taohong"));
			return false;			
		}
		var isLoadNewFile=ocxObj.WebGetMsgByName("isLoadNewFile");
		//如果修改正文的时候重新打开了一个文件则修改标记的值，用来记录流程日志
		if("true"==isLoadNewFile){
			try{
				var loadFileFlagObj;
				// 公文
				if(typeof(this.isLoadNewFileEdoc)!="undefined"&&this.isLoadNewFileEdoc!=null){
					this.isLoadNewFileEdoc=true;
				}							
			}catch(e){
				alert(e);
			}
		}
		var state =false;
		if(this.isToPdf){
    		//如果是Word转PDF正文，设置转化后的PDF正文的ID，并且调用WEBSAVEPDF保存方法
			if(this.newPdfId){
				ocxObj.WebSetMsgByName("newPdfFileId", this.newPdfId);
			}
    		ocxObj.WebSetMsgByName("toFileType","pdf");
    		ocxObj.WebSetMsgByName("realFileType","pdf");
    		state = ocxObj.WebSavePDF();
    		if(ocxObj.WebGetMsgByName("SAVETYPE") != "success"){
    			return false;
    		}
    		//设置JS变量，清空参数。以免保存office正文的时候将这些参数传递到了后台。
    		this.isToPdf = false;  
    		//WebSetMsgByName 调用这个接口的时候会修改 ocxObj.Status的值，所以返回true的时候才设置
    		if(state){
    			ocxObj.WebSetMsgByName("newPdfFileId","");
    			ocxObj.WebSetMsgByName("toFileType","");
    		}
		}else{
			if(!checkFileSize(ocxObj.WebLocalFileSize()/1024,this.officeOcxUploadMax, ocxObj)){
		    	return false;
		    }
			//本地安装的是永中office的时候，wps正文要置为只读状态
			var isYozoOffice = ocxObj.WebApplication(".eio");;
			if((this.fileType == ".wps" || this.fileType == ".et" || this.fileType == "wps" || this.fileType == "et") && isYozoOffice){
				//"本地安装的是永中Office软件，不能保存wps正文，请安装WPS或者微软Office来操作！";
				alert(getOfficeLanguage("alert_YozoSaveWps"));
				return false;
			}
		    state = ocxObj.WebSave();
		    if(ocxObj.WebGetMsgByName("SAVETYPE") != "success"){
    			return false;
    		}
		}
		
		if(ocxObj.WebGetMsgByName("editType")=="clearDocument"){
			ocxObj.WebSetMsgByName("editType","");
		}
		if(state==false){
			if(ocxObj.WebGetMsgByName("MD5Equals")){
				ocxObj.alert(ocxObj.WebGetMsgByName("MD5Equals"));
			}else if(ocxObj.Status.indexOf("versionError")>=0){  
		    	//版本不一致.
		        ocxObj.alert(getOfficeLanguage("alert_err_OcxVer"));
		    }else if(ocxObj.Status.indexOf("Please Install Adobe PDF")>=0){
		    	//安装PDF虚拟打印机
		        ocxObj.alert(getOfficeLanguage("alert_pleaseInstallAdobePDF"));
		    }else if(ocxObj.Status.indexOf("saveFaile")>=0){
		    	//保存正文失败，后台异常
		    	ocxObj.alert(getOfficeLanguage("alert_saveFaile")); 
		    }else if(ocxObj.Status!=null){
		    	//控件中的提示（文件太大不能提交）
		    	ocxObj.alert(ocxObj.Status); 
		    }
		}
		this.fileSize = ocxObj.WebGetMsgByName("fileSize")
	}
	catch(ea){
		/*var errStr = ea.number & 0xFFFF + ":" + ea.description;
		ocxObj.alert(errStr);*/
	}
	
	return state;
}


function getOfficeExtension(fileType,fileId){
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxHandWriteManager", "ajaxGetOfficeExtension",false);
	requestCaller.addParameter(1, "String", fileId);  
	var ds = requestCaller.serviceRequest();
	if(ds == 'docx' || ds == 'doc' || ds == 'xls' || ds == 'xlsx'){
		fileType = ds;
	}
	return fileType;
}

//是否保留痕迹
function isTrack(){
	var isTrack=true;
	try{
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		isTrack=ocxObj.WebObject.TrackRevisions;
	}catch(e){}
	return isTrack;
}
/**
 * 全屏
 */
HandWrite.prototype.FullSize = function(editType) {
    if (!this.isHandWriteRef())
        return;
    this.checkOpenState();
    var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
    try {
        if (ocxObj.WindowStatus != 0) {
       		
       		if(editType){
       			ocxObj.editType = editType;
       			ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
    			ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));
       		}
        	
            ocxObj.FullSize();
            WebOfficeInsertMenuDisable(ocxObj, true);
        }
        if (ocxObj.WindowStatus == 0) {
            ocxObj.DisableMenu(getOfficeLanguage("menu_FullScreenMode"));
            ocxObj.EnableMenu(getOfficeLanguage("menu_SaveExit"));
        }
        if(handWriteObj.isPrint){
        	ocxObj.WebOpenPrint();
        }
        this.setToolsPrintState(ocxObj);
    } catch (e) {

    }
}

//控件自定义菜单，事件响应函数
function OnCommand(vIndex,vCaption,bCancel){
	var isShowShenYueMenu = true; //是否显示审阅菜单
    var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
    if (vIndex==0){
    	ocxObj.CreateFile();
    }else if (vIndex==1){//打开本地文件，如果需要打开网络上文件,用WebOffice.WebOpen();
    	var fileName=ocxObj.FileName;
		ocxObj.FileName="";//打开文件的时候不需要文件名
		try{
			var openLocalFile= ocxObj.WebOpenLocal();
			
			if(openLocalFile){//打开成功后执行回调函数
				if(typeof(loadFileCallBack)=="function"){
		    		loadFileCallBack();
		    	}
				ocxObj.WebSetMsgByName("isLoadNewFile", "true");
			}
		}catch(e){
			//ocxObj.alert(""+(e.number & 0xFFFF)+e.description);
		}
		//打开文件之后把文件名设置回去
		ocxObj.FileName = getOcxFileName(handWriteObj.fileName,handWriteObj.fileId) + ocxObj.FileType.substring(1);
//		ocxObj.FileName=fileName;//打开文件之后把文件名设置回去
	}else if (vIndex==2){
		var saveRes=handWriteObj.saveLocalFile(ocxObj);
		if(saveRes!="" && typeof(parent.officeOcxOperateOver)=="function"){
			parent.officeOcxOperateOver('saveLocal');
		}
	}else if (vIndex==3) {//文字批注按钮
		handWriteObj.setMenuState(getOfficeLanguage("menu_SginSeal"),handWriteObj.hasSign);
      if(ocxObj.ShowType=="0" && ocxObj.modify==true){//由文档清稿切换到文字修改,如果清稿的时候修改了文字,重新掉入文档
        if(ocxObj.confirm(getOfficeLanguage("alert_cancelClearDocument"))==false){
        	return;
        }
        handWriteObj.reLoad(ocxObj);
      }
      if(ocxObj.LastType==2){//最新的为手写批注
        ocxObj.alert(getOfficeLanguage("alert_ClearDoc"));
        ocxObj.EditType="0,1";
        ocxObj.DisableMenu(getOfficeLanguage("menu_SginSeal"));
      }
      if(ocxObj.LastType==0 || ocxObj.LastType==1){//最新为文字
      	ocxObj.EditType="2,0";
      }
      ocxObj.ShowType="1";
      //切换后初始化隐藏痕迹      
      ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);    	
      ocxObj.EnableMenu(getOfficeLanguage("menu_SaveFile,menu_DisplayTrail,menu_PageSet,menu_ClearTrail"));
      ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_HiddenTrail"));   
      if(handWriteObj.hasAdvanceOcx == true)
        ocxObj.EnableMenu(getOfficeLanguage("menu_HandWritePostil"));
    }else if (vIndex==4){//手写批注按钮 
      if(ocxObj.ShowType=="0" && ocxObj.modify==true){//由文档清稿切换到文字修改,如果清稿的时候修改了文字,重新掉入文档
        if(ocxObj.confirm(getOfficeLanguage("alert_cancelClearDocument"))==false){
        	return;
        }
        handWriteObj.reLoad(ocxObj);
      }else if(handWriteObj.reWrite){
    	  ocxObj.ReWrite();//进行过重新批注后，从文字切换到手写需要重新批注
      }else if(ocxObj.LastType==0 || ocxObj.LastType==1){//最新为文字批注
        if(ocxObj.Pages>0){//当前有手写批注
          ocxObj.alert(getOfficeLanguage("alert_restTrail"));
          ocxObj.EnableMenu(getOfficeLanguage("menu_ResetPostil,menu_CharPostil"));
          ocxObj.ShowType="2";
          ocxObj.EditType="2,0";
          ocxObj.DisableMenu(getOfficeLanguage("menu_HandWritePostil,menu_CheckSeal,menu_SginSeal,menu_DisplayTrail,menu_HiddenTrail,menu_PageSet"));
          return;
        }
      }
      ocxObj.EnableMenu(getOfficeLanguage("menu_CharPostil,menu_ClearTrail"));
      ocxObj.DisableMenu(getOfficeLanguage("menu_HandWritePostil,menu_SaveFile,menu_PageSet"));
      ocxObj.ShowType="2";
      ocxObj.EditType="0,1";
      ocxObj.DisableMenu(getOfficeLanguage("menu_CheckSeal,menu_SginSeal,menu_DisplayTrail,menu_HiddenTrail"));
    } else if (vIndex==5){//文档清稿按钮
    	ocxObj.WebSetMsgByName("editType","clearDocument");
      //保证手写和文字的一直,重新掉入文档
      if(ocxObj.modify==true) {
        //提示用户是否需要保存;
	  	if(ocxObj.confirm(getOfficeLanguage("alert_saveEdit"))==true){
			if(handWriteObj.saveOffice()==false){
				ocxObj.alert(getOfficeLanguage("alert_SaveFalseNotChange"));
				return;
			}
	  	}else{
	  		handWriteObj.reLoad(ocxObj);
	  	}
      }
      if((ocxObj.LastType==0 || ocxObj.LastType==1) && ocxObj.HasHandWriting){
    	  //清稿时如果文字时最新的,这时候需要重新生成批注格式
        ocxObj.ReWrite();
      }
      //为了显示痕迹，此处设置为2,0
      ocxObj.EditType="2,0";
      ocxObj.ShowType = "0";
      try{//当该文档是被保护的文档时，会报js错，try catch 一下
		  ocxObj.ClearRevisions();
      }catch(e){}
      //清稿状态是不保留痕迹的，显示痕迹，隐藏痕迹菜单不需要显示
      ocxObj.EnableMenu(getOfficeLanguage("menu_CheckSeal,menu_CharPostil"));
      ocxObj.DisableMenu(getOfficeLanguage("menu_DisplayTrail,menu_HiddenTrail"));
     
      if(handWriteObj.hasAdvanceOcx == true){
        ocxObj.EnableMenu(getOfficeLanguage("menu_HandWritePostil"));
      } 
      //37299 清稿模式不能盖章
      handWriteObj.setMenuState(getOfficeLanguage("menu_SginSeal"),false);
    }else if (vIndex==6){
    	//重新批注按钮
    	ocxObj.ReWrite();
    	handWriteObj.reWrite=true;
    	ocxObj.DisableMenu(getOfficeLanguage("menu_ResetPostil"));
    	ocxObj.EditType="0,1";
    	ocxObj.ShowType="2";
    } else if (vIndex==10){
    	
    	/* OA-99390在已办中修改已归档并盖章的公文，直接查看正文-印章校验就多出一条非法印章的记录，实际并未再次盖章 */
		var _oldfileName = ocxObj.fileName;
		var realFileId = ocxObj.RecordID;
		if(handWriteObj.originalFileId){
			realFileId = handWriteObj.originalFileId;
		}
		var _fileId = parent.OfficeUtils.getOcxFileName(realFileId);
		if(ocxObj.FileType.indexOf(".") != -1){
			ocxObj.fileName=_fileId+ocxObj.FileType.substring(1);
		}else{
			ocxObj.fileName=_fileId+ocxObj.FileType;
		}
      var mtmpEditType=ocxObj.EditType;
      if (mtmpEditType.substring(0,1)=='4'){   //批注锁定模式
        ocxObj.EditType="1,0"
        ocxObj.WebShowSignature();
        ocxObj.EditType=mtmpEditType;
      }else{
        ocxObj.WebShowSignature();
      }
      ocxObj.fileName = _oldfileName;
    }else if (vIndex==11){//盖章
    	
    	if(handWriteObj.currentPage && handWriteObj.currentPage == "govdocSummary" && typeof(handWriteObj.extendParams.setUpdateContentAndSign)=='function'){
	    	//判断文档是否有编辑权限
			handWriteObj.extendParams.setUpdateContentAndSign();
    	}
   // OA-132249 电子收文签章后显示印章无效
    	var _oldfileName = ocxObj.fileName;
		var realFileId = ocxObj.RecordID;
		if(handWriteObj.originalFileId){
			realFileId = handWriteObj.originalFileId;
		}
		var _fileId = parent.OfficeUtils.getOcxFileName(realFileId);
		if(ocxObj.FileType.indexOf(".") != -1){
			ocxObj.fileName=_fileId+ocxObj.FileType.substring(1);
		}else{
			ocxObj.fileName=_fileId+ocxObj.FileType;
		}
		if(handWriteObj.affairMemberId){
			ocxObj.WebSetMsgByName("affairMemberId",handWriteObj.affairMemberId);
		}	
		if(handWriteObj.affairMemberName){
			ocxObj.WebSetMsgByName("affairMemberName",handWriteObj.affairMemberName);
		}
      handWriteObj._sign(ocxObj);
      ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
      ocxObj.fileName = _oldfileName;
    }else if (vIndex==12){
    	//点击隐藏痕迹
    	ocxObj.WebSetRevision(false,isTrack(),false,isShowShenYueMenu);
    	ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
    	ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));
    }else if (vIndex==13){
    	//点击显示痕迹
    	ocxObj.WebSetRevision(true,isTrack(),false,isShowShenYueMenu);
    	ocxObj.EnableMenu(getOfficeLanguage("menu_HiddenTrail"));
    	ocxObj.DisableMenu(getOfficeLanguage("menu_DisplayTrail"));
    }else if (vIndex==14){
    	//点击只读状态得“浏览文字”按钮
    	ocxObj.ShowType="1";
    	ocxObj.DisableMenu(getOfficeLanguage("menu_BrowseChar"));
    	ocxObj.EnableMenu(getOfficeLanguage("menu_BrowseHandWrite,menu_DisplayTrail,menu_CheckSeal,menu_SaveFile"));
    }else if (vIndex==15){
    	//点击只读状态得“浏览手写”按钮
        ocxObj.ShowType="2";
    	ocxObj.EnableMenu(getOfficeLanguage("menu_BrowseChar"));
    	ocxObj.DisableMenu(getOfficeLanguage("menu_BrowseHandWrite,menu_DisplayTrail,menu_HiddenTrail,menu_CheckSeal,menu_SaveFile"));
    }else if(vIndex==100){
      ocxObj.alert(getOfficeLanguage("alert_Ocx")+" "+ocxObj.VersionEx()+"("+ocxObj.Version()+")");
      //当excel程序跟控件冲突，互锁时，可以点击版本按钮，一般情况不会出现冲突互锁；特殊情况这样可以解除互锁
      ocxObj.Active(true);
    }else if(vIndex==101){
    	//全屏模式
      handWriteObj.FullSize();
    } else if(vIndex==102){//保存退出
      if(handWriteObj._checkSignUpdate(ocxObj)==false){
           return false;
      }
      var saveSucess = true;
      /*if(parent.editOnline){
    	  saveSucess = parent.editOnlineFunction();
      }*/
      if(handWriteObj.callback!=null){
    	  saveSucess = handWriteObj.callback(this);
		}
      if(handWriteObj.needSave){
			saveSucess=handWriteObj.saveOffice();
	  }
      if(saveSucess){
    	  this.isSave = true;
    	  ocxObj.SmallSize();
    	  if(ocxObj.WindowStatus==1){
    		  ocxObj.DisableMenu(getOfficeLanguage("menu_SaveExit"));
    		  ocxObj.EnableMenu(getOfficeLanguage("menu_FullScreenMode"));
    	  }
    	  handWriteObj.setToolsPrintState(ocxObj);
      }
    }else if(vIndex==-1) {
    	//ocxObj.WebClose();
    }else if(vIndex==-2){
    	//全屏窗口点击关闭后
    	var saveSucess = true;
        if(typeof(parent.editOnline)!='undefined' && parent.editOnline){
        	saveSucess = parent.editOnlineFunction();
        }
        if(handWriteObj.needSave){
			handWriteObj.saveOffice();
		}
    }else if(vIndex==106){
    	//页面设置
    	WebOpenPageSetup(ocxObj);
    }else if(vIndex==107){
    	//弹出打印对话框
      ocxObj.WebOpenPrint();
      if(typeof(parent.officeOcxOperateOver)=="function"){
    	  parent.officeOcxOperateOver('print');
      }
    } else if(vIndex>=200 && vIndex<=205) {
    	//版本菜单切换
    	handWriteObj.shiftVer(ocxObj,vIndex,vCaption);
    }else if(vIndex==108){
    	if (ocxObj.FileType==".doc" || ocxObj.FileType==".docx" || ocxObj.FileType==".wps"){
    		ocxObj.WebObject.PrintPreview();
    	}else if(ocxObj.FileType==".xls" || ocxObj.FileType==".xlsx" || ocxObj.FileType==".et"){
    		ocxObj.WebObject.Application.ActiveWorkbook.PrintPreview();
    	}else{
    		return;
    	}
    }else if(vIndex==109){//修改正文
		//4、是否有合法印章		
		var hasSign=ocxObj.SignatureCount(true)>0;
		if(hasSign && !handWriteObj.isSignOperation){
			ocxObj.alert(getOfficeLanguage("alert_SignNotEdic"));
			return;
		}
		var requestCaller = new XMLHttpRequestCaller(this,
						"ajaxHandWriteManager", "isNowFile", false);
		requestCaller.addParameter(1, "String", handWriteObj.fileId);
		requestCaller.addParameter(2, "String", this.lastUpdateTime);
		var isNowFile = requestCaller.serviceRequest();
		//是否存在时间差
		if(isNowFile == "true"){
		    handWriteObj.reLoad(ocxObj);
		}
		if(handWriteObj.isFullSize){
			handWriteObj.FullSize();
		} 
		var canSign=handWriteObj.hasSign;//是否有签章权限
		if(typeof(parent.parent.updateContent)=='function'){
		  parent.parent.updateContent();
		}else{
			parent.showOfficeFrameDiv();
			handWriteObj.ModifyContent(canSign,handWriteObj.canWrite);
		}
		handWriteObj.contentUpdate=true;
		//从组件中修改正文，回写页面参数，解决此问题
		//仅公文使用，是否从页签中修改了正文
		if(typeof(parent.changeWord)!="undefined"&&parent.changeWord!=null){
			 parent.changeWord=true;
		}		
		//可以修改正文，就可以打开正文
		ocxObj.EnableMenu(getOfficeLanguage("menu_OpenFile,menu_ClearTrail"));
    }else if(vIndex==18){
    	if(handWriteObj.HasSpecialSignature(ocxObj)){
		  	ocxObj.alert(getOfficeLanguage("alert_SignNotEdic"));
		  	return;
    	}
    	parent.genBarCode(".gif");
    }else if(vIndex==110){
    	handWriteObj.repairContent();
    }else{
    	//alert('编号:'+vIndex+'\n\r'+'标题:'+vCaption+'\n\r'+'请根据这些信息编写具体功能');
    }    
}

HandWrite.prototype.taoHong4Form=function(taoHongCallBack){
	this.checkOpenState();
	var ocxObj = document.getElementById("WebOffice2015");
	try{
		var displayNameStr = "";
		//1.获取所有书签
		var bookMarks =  ocxObj.Activedocument.BookMarks;
		var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;
		if(bookMarks){
			var mCount = bookMarks.Count;
			if(mCount&&mCount>0){
				for (var i = 1; i < mCount + 1; i++){
					var markName="";
					if(isChrome){
						markName = bookMarks.Item(i).Name;
					}else{
						markName = bookMarks(i).Name;
					}
					if(i==1){
						displayNameStr += markName;
					}else{
						displayNameStr += ","+markName;
					}
				}
				taoHongCallBack(handWriteObj.formDataId,displayNameStr);
			}
		}
	}catch(e){}
}

HandWrite.prototype.taoHongHt=function(formdata){
	var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
	//可编辑状态，不然的话数据没法套进去
	var  _tempEditType = ocxObj.editType;
	ocxObj.editType = "1,0";
	ocxObj.WebSetRevision(false,true,false,true);
	for(var i=0;i<formdata.data.length;i++){
		var formBean = formdata.data[i];
		if(formBean){
			var beanVal = formBean.val;
			var beanName = formBean.name;
			var beanType = formBean.type;
			if(beanType == "image" || beanType == "handwrite" || beanType == "barcode" || beanType == "mapphoto"){
				ocxObj.WebSetMsgByName("inputType",beanType);
				if((beanType == "image" || beanType == "mapphoto") && beanVal){
					var valArray = beanVal.split("_");
					beanVal = valArray[0];
					ocxObj.WebSetMsgByName("createDate",valArray[1]);
				}
				try{//OA-125385
					ocxObj.WebInsertImageEx(beanName,beanVal,true,3,true);
				}catch(e){//兼容老版本
					ocxObj.WebInsertImageEx(beanName,beanVal,true,3);
				}
			}else if(beanType == "flowdealoption"){
				if(beanVal && beanVal.indexOf("@signet@") != -1){
					var str = beanVal.match(/@signet@(\S*)@signet@/);
					if(str && str.length > 0){
						beanVal = beanVal.replace(str[0],"");
					}
				}
				ocxObj.WebSetBookmarks(beanName,beanVal);
			}else {
				ocxObj.WebSetBookmarks(beanName,beanVal);
			}
		}
    }
	ocxObj.editType = _tempEditType;
	ocxObj.WebSetRevision(false,true,false,true);
}

//function taoHongHt(formdata){//
//	var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
//	//可编辑状态，不然的话数据没法套进去
//	ocxObj.editType = "2,1";
//	for(var i=0;i<formdata.data.length;i++){
//	  ocxObj.WebSetBookmarks(formdata.data[i].name,formdata.data[i].val);
//    }
//}

//保存到本地文件，全部保存为可编辑状态，印章变灰；
//保存到本地后，脱离系统，无法保证保存到本地的文件不被修改，除非使用专业的电子签章系统
//以前只对wps，word保存后全部可编辑，修改为所有全部可以编辑包括.et,.xls文件；
//以前如果只读隐藏痕迹保留会删除痕迹，原因是以前存储后为只读，office2007问题每次打开都显示痕迹还无法隐藏；现在保存可编辑后不在删除痕迹保存
HandWrite.prototype.saveLocalFile=function(ocxObj){
  var saveRes=false;
  var isProtect = IsOfficeProtection(ocxObj);
  var isProjectB = isProtect == 0 ? false : true;
  var isFormTaohong  = this.canTaohong ? this.canTaohong :false;
  var oldEditType = ocxObj.editType;


  if(isProjectB){//有锁定
	  ocxObj.editType='1,0';
  }
  
  //表单套红不置灰
  if(!isFormTaohong){  
	  //保存本地文件前把印章变灰，使印章实效
	  try{
			ocxObj.SignatureColor(false);
	  }catch(e){}
  }
 
  var _oldfileName = ocxObj.fileName;
	var _fileId = parent.OfficeUtils.getOcxFileName(ocxObj.RecordID);
	if(ocxObj.FileType.indexOf(".") != -1){
		ocxObj.fileName=_fileId+ocxObj.FileType.substring(1);
	}else{
		ocxObj.fileName=_fileId+ocxObj.FileType;
	}
  
  var isSign = ocxObj.SignatureCount(true)>0;
  if(isSign){
	  ocxObj.WebSetProtect(true,"");
  }
  else if(this.HasSpecialSignature(ocxObj)){
	  ocxObj.WebSetProtect(isProtect,"");
  }
  saveRes=this.dealTrackSaveLocalFile(ocxObj,false,isProjectB);
  
  //表单套红不置灰
  if(!isFormTaohong){
	  if(setSignatureBlack != 'true'){  //部门归档本身就是暗色的就不需要变回彩色了。
		  try{
				ocxObj.SignatureColor(true);
		  }catch(e){}
	  }
  }
  
  if(isProjectB){//有锁定
	  ocxObj.editType = oldEditType;
  }
  ocxObj.fileName=_oldfileName;
  ocxObj.WebSetProtect(isProtect,"");
  return saveRes;
}
/**保存到本地是否需要设置随机密码**/
HandWrite.prototype.setPasswordSaveLocalFile=function(ocxObj,setPassword,isProtect){
	var ret  = false;
	if(setPassword){
		var randomPass=""+Math.random();  
		ocxObj.WebSetProtect(true,randomPass);
		var tempFileName=ocxObj.FileName;
		//获取保存正文文件名。
		var subjectValue=handWriteObj.saveLocalFileName;
		try{
			if(subjectValue!=null&&subjectValue!=""&&subjectValue!="<点击此处填写标题>"){
			    var newSubject=subjectVerify(subjectValue);
				if(newSubject.length != 0){
				    //解决文件名如abc.ef保存到本地以后不会追加扩展名，这个地方判断用程序加扩展名
					if(newSubject.indexOf(".")>=0 && ocxObj.FileType!=null){
						ocxObj.FileName=newSubject+ocxObj.FileType;
					}else{
						ocxObj.FileName=newSubject;
					}
				}
			}
			ret = ocxObj.WebSaveLocal();
			window.setTimeout(function(){
				var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
				ocxObj.FileName=tempFileName;
			},1000);
		}catch(e){
			window.setTimeout(function(){
				var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
				ocxObj.FileName=tempFileName;
			},1000);
		};
		ocxObj.WebSetProtect(false,randomPass);
	}else{
	  try{
      //如果正文中有印章，保存前则设置为受保护的状态
	  if(this.HasSpecialSignature(ocxObj)){
	     ocxObj.WebSetProtect(isProtect,"");
	  }else if(ocxObj.SignatureCount(true)>0){
    	  try{
			  ocxObj.SignatureColor(false);
		  }catch(e){}
    	  ocxObj.WebSetProtect(true,"");
      }else{
    	  ocxObj.WebSetProtect(false,"");
      }
      var tempFileName=ocxObj.FileName;
		var	subjectValue=handWriteObj.saveLocalFileName;
		try{ 
			if(subjectValue!=null&&subjectValue!=""&&subjectValue!="<点击此处填写标题>"){
				var newSubject=subjectVerify(subjectValue);
				if(newSubject.length != 0){
					if(newSubject.indexOf(".")>=0 && ocxObj.FileType!=null){
						ocxObj.FileName=newSubject+ocxObj.FileType;
					}else{
						ocxObj.FileName=newSubject;
					}
				}
			}
			ret = ocxObj.WebSaveLocal();
			window.setTimeout(function(){
				var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
				ocxObj.FileName=tempFileName;
			},1000);
		}catch(e){
			window.setTimeout(function(){
				var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
				ocxObj.FileName=tempFileName;
			},1000);
		};
    }catch(e){};
	}
	return ret ;
}
/**
 * office正文"保存文件"到本地时，替换标题中包含office标题不支持的特殊字符
 * office标题不支持{ \ / : * ? " <> | },协同标题不支持{ }，还有{? : * /}需要校验<br>
 * @return
 */
function subjectVerify(subject){
	var ret="";
	try{
		if(typeof subject=='string' && subject.constructor==String){
			ret=subject;
		}else if(typeof subject=='object'){
			ret=subject.value;
		}else{
			return ret;
		}
	}catch(e){
		return "";
	}
	try {
		while (ret.indexOf("?") >= 0 || ret.indexOf(":") >= 0 || ret.indexOf("*") >= 0 || ret.indexOf("/") >= 0|| ret.indexOf("\"") >= 0|| ret.indexOf("|") >= 0
				|| ret.indexOf("\\") >= 0|| ret.indexOf("<") >= 0|| ret.indexOf(">") >= 0|| ret.indexOf("\t") >= 0
				||ret.indexOf("\xA0")>= 0 || ret.indexOf("\r") >= 0|| ret.indexOf("\n") >= 0 || ret.indexOf("•") >= 0) {
			ret = ret.replace("?", "").replace(":", "").replace("*", "").replace("\t", "").replace("\"", "").replace("|", "")
					.replace("/", "").replace("\\", "").replace("<", "").replace(">", "")
					.replace("\xA0", "\x20")
					.replace("\r", "")
					.replace("\n", "")
					.replace("•","");
		}
	} catch (e) {
		ret=subject;
		while (ret.indexOf("?") >= 0) {
			ret = ret.replace("?", "");
		}
		while (ret.indexOf(":") >= 0) {
			ret = ret.replace(":", "");
		}
		while (ret.indexOf("*") >= 0) {
			ret = ret.replace("*", "");
		}
		while (ret.indexOf("/") >= 0) {
			ret = ret.replace("/", "");
		}
		while (ret.indexOf("\\") >= 0) {
			ret = ret.replace("\\", "");
		}
		while (ret.indexOf("<") >= 0) {
			ret = ret.replace("<", "");
		}
		while (ret.indexOf(">") >= 0) {
			ret = ret.replace(">", "");
		}
		while (ret.indexOf("\t") >= 0) {
			ret = ret.replace("\t", "");
		}
		while (ret.indexOf("\xA0") >= 0) {
			ret = ret.replace("\xA0", "\x20");
		}
		while (ret.indexOf("\"") >= 0) {
			ret = ret.replace("\"", "");
		}
		while (ret.indexOf("|") >= 0) {
			ret = ret.replace("|", "");
		}
		while (ret.indexOf("\r") >= 0) {
			ret = ret.replace("\r", "");
		}
		while (ret.indexOf("\n") >= 0) {
			ret = ret.replace("\n", "");
		}
		while (ret.indexOf("•") >= 0) {
			ret = ret.replace("•", "");
		}
	}
	return ret;
}
/**保存到本地时候,对痕迹的处理,由于office问题,保存到本地默认是显示痕迹,只能先删除痕迹然后撤销**/ 
HandWrite.prototype.dealTrackSaveLocalFile=function(ocxObj,setPassword,isProtect){
	if(isProtect){
		ocxObj.WebSetProtect(false,"");
	}
	var ret = false;
	if(ocxObj.FileType==".doc" || ocxObj.FileType == ".docx" || ocxObj.FileType==".wps"){
		//acceptAllRevisions(ocxObj);  //清除痕迹
		if(isProtect){
			ocxObj.WebSetProtect(true,"");
		}
		ret = this.setPasswordSaveLocalFile(ocxObj,setPassword,isProtect);
		//Word或者Wps正文保存到本地是否保留修改痕迹,系统参数控制
		this.isRetainedTraces = ocxObj.WebGetMsgByName("isRetainedTraces");
		if(typeof(this.isRetainedTraces)!="undefined" && (this.isRetainedTraces == false || this.isRetainedTraces == "false")){
			ocxObj.WebAcceptAllRevisions(ret);//清除保存到本地文档的痕迹
		}
		if(typeof(this.isRemoveTrace)!="undefined" && (this.isRemoveTrace == true || this.isRemoveTrace == "true")){//保存本地强制清除痕迹
			ocxObj.WebAcceptAllRevisions(ret);//清除保存到本地文档的痕迹
		}
		//ocxObj.WebObject.Undo();         //撤销上一步的操作 
	}else{
		ret = this.setPasswordSaveLocalFile(ocxObj,setPassword,isProtect);
	}
	if(isProtect){
		ocxObj.WebSetProtect(true,"");
	}
	return ret ;
}

/**
 * 清除所有的痕迹
 * @param ocxObj
 */
function acceptAllRevisions(ocxObj){
	try{
		ocxObj.ClearRevisions();
	}catch(e){
		
	}
}


//开页面配置对话框
function WebOpenPageSetup(ocxObj){
	try{
	if (ocxObj.FileType==".doc" || ocxObj.FileType==".docx" || ocxObj.FileType==".wps"){
	  //ocxObj.WebObject.Application.Dialogs(178).Show();
	  document.getElementById("WebOffice2015").ShowDialog(5);
	}
	if(ocxObj.FileType==".xls" || ocxObj.FileType==".xlsx"){
		var browser = new Browser();
		if(browser.isChrome){
			ocxObj.WebObject.Application.Dialogs.Item(7).Show();
		}else{
			ocxObj.WebObject.Application.Dialogs(7).Show();
		}
	}
   }catch(e){alert(e.description);}
}

/**
 * 设置控件菜单状态
 * @param ocx
 * @param menuName
 * @param state
 */
HandWrite.prototype.setMenuState = function(menuName,state){
  var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
  if(state){
	  ocxObj.EnableMenu(menuName);
  }else{
	  ocxObj.DisableMenu(menuName);
  }
}
/**
 * 盖章
 */
HandWrite.prototype._sign = function(ocxObj) {

	// 有专业签章，不能再盖图片章
	if (this.HasSpecialSignature(ocxObj)) {
		ocxObj.alert(getOfficeLanguage("alert_info_canNotSign"));
		return false;
	}
	try {
		var browser = new Browser();
		var officeOBJ =  document.getElementById("WebOffice2015");
		// 新建时候不进行同时修改校验
		if (ocxObj.EditType == "1,0") {
			ocxObj.WebSetMsgByName("currentUserId", this.userId);
			this.isSignOperation = true;
			return ocxObj.WebOpenSignature();
		}

		var isModify = this.checkModify(this.contentId, ocxObj);
		if (isModify != false) {
			return false;
		}

		if (this._checkSignUpdate(ocxObj)) {
			var srcEditType = "";
			var tempStr;
			if (ocxObj.EditType == "4,0") {
				srcEditType = "4,0";
				ocxObj.EditType = "1,0";
			}
			var disPageBlank = true;
			if (ocxObj.FileType == ".doc" || ocxObj.FileType == ".wps") {
				disPageBlank = ocxObj.WebObject.ActiveWindow.View.DisplayPageBoundaries;
				if (disPageBlank == false) {
					ocxObj.WebObject.ActiveWindow.View.DisplayPageBoundaries = true;
				}
			}
			ocxObj.WebSetMsgByName("currentUserId", this.userId);
			if (ocxObj.WebOpenSignature()) {
				// 盖章后，要想移动印章，就不能在保护文档，所有做了一个功能，盖章后先记录当前文字，保存的时候，检查文字是否改变
				if (ocxObj.FileType == ".doc") {
					this.wordTextContent = ocxObj.WebObject.Content.Text;
				}
			} else {
				if (srcEditType == "4,0") {
					ocxObj.EditType = "4,0";
				}
			}

			if (disPageBlank == false) {
				ocxObj.WebObject.ActiveWindow.View.DisplayPageBoundaries = false;
			}
		}

		ocxObj.WebSetFoucs();

		this.isSignOperation = true;
	} catch (e) {
	}
}
/**
  如果盖过章,检查盖章后是否进行了文字修改
**/
HandWrite.prototype._checkSignUpdate=function(ocxObj){
try{
  if(ocxObj.SignatureCount(true)>0 && this.wordTextContent!=""){//已经进行过盖章
    tempStr=ocxObj.WebObject.Content.Text;
    if(this.wordTextContent!=tempStr){
      ocxObj.alert(getOfficeLanguage("alert_SignNoEffect"));
      this._loadOffice();
      WebOpenSignature();
      return false;
    }
  }
  }catch(e){}
  return true;
}
//检查contentId的文档是否有人修改,无人修改时返回"false",有人修改时返回修改人员的用户名称
HandWrite.prototype.checkModify=function(contentId,ocxObj){ 
  if((ocxObj.EditType!="0,0" && ocxObj.EditType!="4,0" )|| this.isSignOperation){
	  //已经是编辑模式，已经标记为自己修改，避免多次校验,签章模式也为4,0,所以另外添加参数isSignOperation来标识是否做了签章操作。
      return false;
  }
  var requestCaller = new XMLHttpRequestCaller(this, "ajaxHandWriteManager", "editObjectState",false);
  requestCaller.addParameter(1, "String", contentId);  
  var ds = requestCaller.serviceRequest();
  if(ds.get("curEditState")=="true"){
  	ocxObj.alert(getOfficeLanguage("alert_NotEdit",ds.get("userName")));    
    return true;
  }
  return false;
}

HandWrite.prototype.setMenuStateByEditType=function(ocxObj,editType,isSign){
  if(editType=="2,1"){  
	//可以修改正文，就可以打开正文
	ocxObj.EnableMenu(getOfficeLanguage("menu_OpenFile"));
	if(ocxObj.LastType==2){
		//目前显示是手写批注
    	if(ocxObj.ShowType!="2"){
    		ocxObj.ShowType="2";
    	}//浏览的时候已经切换到文字模式,目前手写是最新的,切换到手写模式
    	ocxObj.EnableMenu(getOfficeLanguage("menu_CharPostil,menu_ClearTrail"));	  
  	}else{
    	if(ocxObj.ShowType!="1"){
    		ocxObj.ShowType="1";
    	}
    	ocxObj.WebSetRevision(false,true,false,this.isShowShenYueMenu);
    	ocxObj.EnableMenu(getOfficeLanguage("menu_ClearTrail,menu_PageSet,menu_DisplayTrail"));
    	ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
    	if(this.hasAdvanceOcx == true){
        ocxObj.EnableMenu(getOfficeLanguage("menu_HandWritePostil"));
      }
  	}
  	ocxObj.DisableMenu(getOfficeLanguage("menu_BrowseChar,menu_BrowseHandWrite"));
  	if(isSign){
  		this.hasSign=true;//有签名印章的权限
  		if(ocxObj.LastType==0 || ocxObj.LastType==1){
  			ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));//当最新为文字的时候才可以显示印章
  		}else if(ocxObj.LastType==2){
  			ocxObj.DisableMenu(getOfficeLanguage("menu_CheckSeal"));
  		}
  	}
  }else if(editType=="0,0" || editType=="4,0"){
  	if(ocxObj.ShowType=="1"){
  	//文字批注
  		ocxObj.EnableMenu(getOfficeLanguage("menu_CheckSeal,menu_DisplayTrail"));  		
  	}
  	else if(ocxObj.ShowType=="2"){
  	//手写批注
  		ocxObj.DisableMenu(getOfficeLanguage("menu_CheckSeal,menu_DisplayTrail"));
  	}
  	if(this.currentPage && this.currentPage == "govdocSummary" && (this.actionCanSign == "true" || this.actionCanSign == true)){
  	  	ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
  	}else{
  		ocxObj.DisableMenu(getOfficeLanguage("menu_SginSeal"));
  	}
  }
  
}
HandWrite.prototype.ModifyContent=function(isSign,canWrite){
try{
  var isShowShenYueMenu = true;
  var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
  var requestCaller = new XMLHttpRequestCaller(this,"ajaxHandWriteManager", "isNowFile", false);
  requestCaller.addParameter(1, "String", handWriteObj.fileId);
  requestCaller.addParameter(2, "String", ocxObj.WebGetMsgByName("OfficeUpdateTime"));
  var isNowFile = requestCaller.serviceRequest();
  //是否存在时间差
  if(isNowFile == "true"){
  handWriteObj.reLoad(ocxObj);
  }
  this.checkOpenState();
  if(this.curMenuID!=200 && this.curMenuID!=0){
	  ocxObj.alert(getOfficeLanguage("alert_CurrectVerNoEdit"));
	  return;
  } 
  var _oldfileName=setFileName(ocxObj);
  if(ocxObj.SignatureCount(true)>0 && !handWriteObj.isSignOperation){
	ocxObj.fileName=_oldfileName;
	  ocxObj.alert(getOfficeLanguage("alert_SignNotEdic"));
	  return false;
  }  
  
  //已经是编辑模式 或者 清稿模式，不在作任何操作  
  if(ocxObj.EditType=="2,1" || ocxObj.EditType=="0,1" || ocxObj.EditType=="2,0" || ocxObj.ShowType=="0"){
	  ocxObj.WebSetRevision(false,isTrack(),false,this.isShowShenYueMenu);
  	  ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
  	  ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));
	  ocxObj.fileName=_oldfileName;
	  return true;
  }

  var isModify=this.checkModify(this.contentId,ocxObj);
  if(isModify!=false){  
	  ocxObj.fileName=_oldfileName;
    return false;
  }
  //公文可以进行手写批注，其他不能进行手写批注
  if(typeof(canWrite)!="undefined" && canWrite=="true" ){
  	ocxObj.EditType="2,1";
  	this.editType = "2,1";
  	this.canEdit="true";
  }else{
	ocxObj.EditType="2,0";
	this.editType = "2,0";
	this.canEdit="true";
  }
  //本地安装的是永中office的时候，wps正文要置为只读状态
  var isYozoOffice = ocxObj.WebApplication(".eio");
  if((this.fileType == ".wps" || this.fileType == ".et" || this.fileType == "wps" || this.fileType == "et") && isYozoOffice && ocxObj.EditType != "0,0"){
	 //本地安装的是永中Office，不支持对wps正文的编辑，系统自动将正文置为只读状态!
	 alert(getOfficeLanguage("alert_YozoModifyWps"));
	 ocxObj.EditType = "0,0";
	 ocxObj.fileName=_oldfileName;
	 return false;
  }
  
  this.setMenuStateByEditType(ocxObj,ocxObj.EditType,isSign);
  //设置文档痕迹保留的状态 参数1:不显示痕迹 参数2:不保留痕迹 参数3:不打印时有痕迹 参数4:不显痕迹处理工具
  ocxObj.WebSetRevision(false,true,false,isShowShenYueMenu);//切换到修改状态时默认为不隐藏痕迹
  this.adjustMenu(ocxObj);
  if(IsOfficeProtection(ocxObj)==1){//文档保护时，不能批注
	 ocxObj.DisableMenu(getOfficeLanguage("menu_HandWritePostil"));
  }
  if(isSign){
	  ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
  }
  ocxObj.EnableMenu(getOfficeLanguage("menu_PageSet"));
  ocxObj.EnableMenu(getOfficeLanguage("menu_OpenFile"));
  ocxObj.fileName=_oldfileName;
  this.contentUpdate = true;
  return true;
}catch(ea){/*var errStr=ea.number & 0xFFFF;errStr=errStr+":"+ea.description;alert(errStr);*/}
	return false;
}

/*整体调整菜单,对于xls去掉手写批准相关,只有起草才有打开文件菜单*/
HandWrite.prototype.adjustMenu=function(ocxObj)
{
  try{
    var docType=ocxObj.FileType.toLowerCase();
    if(docType==".xls" || docType==".et"){
      ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_HandWritePostil,menu_ClearTrail,menu_ResetPostil,menu_HiddenTrail,menu_DisplayTrail,menu_BrowseChar,menu_BrowseHandWrite"));
    }
    if(docType==".et"){
    	ocxObj.DisableMenu(getOfficeLanguage("menu_PageSet"));
    }
    //有印章的时候不允许清稿
    if(this.HasSpecialSignature(ocxObj)) {
    	ocxObj.DisableMenu(getOfficeLanguage("menu_ClearTrail"));
    }
    //2005917_001zhangh begain
    //新建或者修改正文的时候才有打开文件,保存文件
    if(ocxObj.EditType!="1,0"&&ocxObj.EditType!="2,1"){
      ocxObj.DisableMenu(getOfficeLanguage("menu_OpenFile"));
    }
    var mtmpEditType=ocxObj.EditType.substring(0,1);
    if(mtmpEditType!="0" && mtmpEditType!="4" ){
    	this.enableRepairContent(ocxObj);
    }
    //2005917_001zhangh end

      ocxObj.WebToolsVisible(getOfficeLanguage('menu_A8Col'),false);
      ocxObj.ShowMenu="1";
      //setAllToolsState(ocxObj,false);
      //根据页面设置控制菜单
      this.setToolsPrintState(ocxObj);
      if(this.officecanSaveLocal=="false"){
      	//暂时屏蔽如下行，金格控件问题，禁止拷贝后，无法生成手写批注，控件更新后，再屏蔽拷贝功能
      	//ocxObj.CopyType=false;
      	ocxObj.DisableMenu(getOfficeLanguage("menu_SaveFile"));
      	//ocxObj.DisableMenu(getOfficeLanguage("menu_SaveExit"));
      	ocxObj.UIControl = true;
      }else{
    	  ocxObj.UIControl = false;
      }
      //公文模块才需要进行控制
      if((typeof(this.edocType)!='undefined' && this.edocType) || parent.document.getElementById("edocType")){
      		this.isAuthorityToCopy(ocxObj);
      		if(this.actionCanSign!="" && !this.actionCanSign){
      	  	  //电子签章按钮控制
      		  this.ActionUI_Update(0);
      	  }
      }
      if(this.isFromRegsitPendingList){  //登记页面清除痕迹 
		  ocxObj.ClearRevisions();  //清除痕迹
      }
      if(this.hasPDF417Manager && typeof this.CopyRight && (ocxObj.FileType == ".doc" || ocxObj.FileType == ".docx") 
    		  && (ocxObj.EditType == "1,0" || ocxObj.EditType == "2,0" || ocxObj.EditType == "3,0" || ocxObj.EditType == "2,1" || ocxObj.EditType == "1,1") || ocxObj.EditType == "3,1"){
    	  ocxObj.EnableMenu(getOfficeLanguage("menu_BarCode"));
      }
    }catch(e){}
}


/*整体调整菜单,对于xls去掉手写批准相关,只有起草才有打开文件菜单*/
HandWrite.prototype.adjustMenuBeforeOpen=function(ocxObj){
	  try{
		    var docType=ocxObj.FileType.toLowerCase();
		    if(docType==".xls" || docType==".et"){
		      ocxObj.DisableMenu(getOfficeLanguage("menu_CharPostil,menu_HandWritePostil,menu_ClearTrail,menu_ResetPostil,menu_HiddenTrail,menu_DisplayTrail,menu_BrowseChar,menu_BrowseHandWrite"));
		    }
		    if(docType==".et"){
		    	ocxObj.DisableMenu(getOfficeLanguage("menu_PageSet"));
		    }
		    //有印章的时候不允许清稿
		    if(this.HasSpecialSignature(ocxObj)) {
		    	ocxObj.DisableMenu(getOfficeLanguage("menu_ClearTrail"));
		    }
		    //2005917_001zhangh begain
		    //新建或者修改正文的时候才有打开文件,保存文件
		    if(ocxObj.EditType!="1,0"&&ocxObj.EditType!="2,1"){
		      ocxObj.DisableMenu(getOfficeLanguage("menu_OpenFile"));
		    }
		    var mtmpEditType=ocxObj.EditType.substring(0,1);
		    if(mtmpEditType!="0" && mtmpEditType!="4" ){
		    	this.enableRepairContent(ocxObj);
		    }
		    //2005917_001zhangh end

		      ocxObj.WebToolsVisible(getOfficeLanguage('menu_A8Col'),false);
		      ocxObj.ShowMenu="1";
		      //setAllToolsState(ocxObj,false);
		      //根据页面设置控制菜单
		      this.setToolsPrintState(ocxObj);
		      if(this.officecanSaveLocal=="false"){
		      	//暂时屏蔽如下行，金格控件问题，禁止拷贝后，无法生成手写批注，控件更新后，再屏蔽拷贝功能
		      	//ocxObj.CopyType=false;
		      	ocxObj.DisableMenu(getOfficeLanguage("menu_SaveFile"));
		      }
		      if(this.hasPDF417Manager && typeof this.CopyRight && (ocxObj.FileType == ".doc" || ocxObj.FileType == ".docx") 
		    		  && (ocxObj.EditType == "1,0" || ocxObj.EditType == "2,0" || ocxObj.EditType == "3,0" || ocxObj.EditType == "2,1" || ocxObj.EditType == "1,1") || ocxObj.EditType == "3,1"){
		    	  ocxObj.EnableMenu(getOfficeLanguage("menu_BarCode"));
		      }
		    }catch(e){}
}

/*整体调整菜单,对于xls去掉手写批准相关,只有起草才有打开文件菜单*/
HandWrite.prototype.adjustMenuAfterOpen=function(ocxObj){
	  try{
		  this.initBackUpMenuState(ocxObj);
	      if(this.officecanSaveLocal=="false"){
	      	ocxObj.UIControl = true;
	      }else{
	    	  ocxObj.UIControl = false;
	      }
	      //公文模块才需要进行控制
	      if((typeof(this.edocType)!='undefined' && this.edocType) || parent.document.getElementById("edocType")){
	      		this.isAuthorityToCopy(ocxObj);
	      		if(this.actionCanSign!="" && !this.actionCanSign){
	      	  	  //电子签章按钮控制
	      		  this.ActionUI_Update(0);
	      	  }
	      }
	      if(this.isFromRegsitPendingList){  //登记页面清除痕迹 
			  ocxObj.ClearRevisions();  //清除痕迹
	      }
	    }catch(e){}
}
//是否有复制正文的权限 
//如果节点有【(正文修改||正文保存)&&没有印章】的权限，则允许复制office正文。
HandWrite.prototype.isAuthorityToCopy = function(ocxObj){
	 var bool=false;
	 //var edocType=parent.document.getElementById("edocType").value;
	 var _oldfileName=setFileName(ocxObj);
	 //1.发文，收文，签报 新建页面具有拷贝权限
	var hasSign=ocxObj.SignatureCount(true)>0;
 	 if(this.currentPage && this.currentPage=="newEdoc" && !hasSign){
 		ocxObj.CopyType=true;
 		ocxObj.fileName=_oldfileName;
 		return;
 	 }
 	 //2、中间处理节点由节点权限来判断。
	 //if(parent.officecanPrint=="true") bool= true;
	 if(this.officecanSaveLocal=="true")  bool= true;	
	// 取detail对话框右边showDialogram.jsp页面中的js变量canEdit(是否有修改正文的权限)  
	 var canEdit = false;
     if (typeof(this.canEdit)!="undefined" && this.canEdit=="true") {
        canEdit = true;
     }
     if(canEdit){
        bool=true; 
     }
	 //4、是否有合法印章		
	 var hasSign=ocxObj.SignatureCount(true)>0;
	 
	 if(bool && !hasSign)  {
	 	ocxObj.CopyType=true;
	 }else {
	 	ocxObj.CopyType=false;
	 	//必须设置成0,0,不要随意修改，否则可以拷贝
	 	ocxObj.EditType="0,0";
	 }
	 ocxObj.fileName=_oldfileName;
}
HandWrite.prototype.WebOpenSignature=function(isFullSize){
  if(!this.isHandWriteRef()){
	  return;
  }
  this.checkOpenState();
  var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
  //<!--****修改号="20060607zhangh_003"  区域="1"  *****************开始-->
  //如果上次编辑为手写批注模式最新为手写，当前不是清稿模式，不能盖章
  //                          最新为文字（上次编辑为文字或者清稿），当前为手写批注模式，不允许盖章
  if((ocxObj.LastType==2 && ocxObj.ShowType!="0") || ((ocxObj.LastType==0 || ocxObj.LastType==1) && ocxObj.ShowType=="2")){
    ocxObj.alert(getOfficeLanguage("alert_NotSign"));
    return;
  }
  //检查当前显示模式，如果是手写批注模式，切换到文字模式
  if(ocxObj.ShowType=="2"){
	  ocxObj.ShowType="1";
  }
  if(ocxObj.EditType=="0,0"){
	  ocxObj.EditType="2,0";
	  ocxObj.WebSetRevision(false,true,false,this.isShowShenYueMenu);
  }
  //<!--****修改号="20060607zhangh_003"  区域="1"  *****************结束-->
  ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
  this.enableRepairContent(ocxObj);
  if(this.affairMemberId){
		ocxObj.WebSetMsgByName("affairMemberId",this.affairMemberId);
  }	
  if(this.affairMemberName){
		ocxObj.WebSetMsgByName("affairMemberName",this.affairMemberName);
  }
  if(handWriteObj.isFullSize || isFullSize){
	  this.FullSize();
  }
}

//当前参数重新掉入文档
HandWrite.prototype.reLoad=function(ocxObj){
	var ret=false;
	try{
  		this.reWrite=false;
  		ret=ocxObj.WebOpen();
  	}catch(ea){var errStr=ea.number & 0xFFFF;errStr=errStr+":"+ea.description;alert(errStr);ret=false;}
  	return ret;
}
//修改正文时，记录修改人，退出时取消修改状态
function OcxUnLoad(){
	try{ 
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		ocxObj.WebClose();
	}catch(e){}
	if(handWriteObj==""){
		return;
	}
	
  try{
	  if(handWriteObj.isLoadOfficeFile==false){
		  return;
	  };
  }catch(e){}
  if(handWriteObj.checkNeedSave()==false){
	  return;
  }
  try {
		var requestCaller = new XMLHttpRequestCaller(this,
				"ajaxHandWriteManager", "deleteUpdateObj", false);
		requestCaller.addParameter(1, "String", handWriteObj.contentId);
		var ds = requestCaller.serviceRequest();
	} catch (e) {}
	removeOfficeDiv();
	  
}
//4,0盖章，也得保存，不管默认是什么编辑状态，花脸统一设置成0，0，不可随意改动。
//每次花脸保存的时候，都会覆盖当前正文，因为保存时候的RECORDID取的是parent.fileId.除非改变这个值
//此函数没有设置这个值，所以有覆盖当前正文的可能。修改时请注意。
HandWrite.prototype.shiftVer = function(ocxObj, mIndex, vCaption) {
	if (mIndex != 200) {// 查看历史版本时,先检查对当前版本的修改是否保存
		if (ocxObj.EditType != "0,0" && ocxObj.EditType != "4,0") {
			// 提示用户是否需要保存;
			if (ocxObj.confirm(getOfficeLanguage("alert_saveEdit")) == true) {
				if (this.saveOffice() == false) {
					ocxObj.alert(getOfficeLanguage("alert_SaveFalseNotChange"));
					return;
				}
			}
		}
		ocxObj.WebSetMsgByName("checkBack", "false");// 显示备份版本时,不需要检查备份
		// 第一次进行版本切换时候,保存当前版本编辑状态
		if (this.curMenuEditType == "") {
			this.curMenuEditType = ocxObj.EditType;
		}
		this.editType = "0,0";
	} else if (this.curMenuEditType != "") {// 切换回当前版本时将编辑状态还原,菜单设置用到
		this.editType = this.curMenuEditType;
	}
	this.fileId = this.getVerMenuDataId(ocxObj, mIndex);
	this._loadOffice();
	ocxObj.DisableMenu(getVerMenuName(mIndex));
	ocxObj.EnableMenu(getVerMenuName(this.curMenuID));
	this.curMenuID = mIndex;
	if (mIndex == 200) {// 切换到当前版本后,设在编辑模式和菜单
		ocxObj.EditType = this.curMenuEditType;
		this.setMenuStateByEditType(ocxObj, this.curMenuEditType, this.hasSign);
	}
}
function taohongLogo(ocxObj){
	//判断套红模板中是否存在logoimg书签
	try{
		var bool=false;
		var ocxObj = document.getElementById("WebOffice2015");
		var webObject =  ocxObj.Activedocument;
		var mCount = webObject.Bookmarks.Count;
		for(i=1;i<mCount+1;i++){
			var markname=webObject.Bookmarks(i).Name;
			if(markname=="logoimg"){bool=true;break;}
		}
		if(bool){
			ocxObj.FuncExtModule.WebInsertImage("logoimg","logoimg.gif",true,4);
		}
	}catch(e){}
}

/**
 * 公文套红
 */
HandWrite.prototype.taohong=function(dataForm,templateUrl,templateType,dataList,opinionArr,isFullSize){
  this.checkOpenState();
  var mObject = document.getElementById("WebOffice2015");
  var ocxObj = mObject.FuncExtModule;
  ocxObj.Template=templateUrl;
  
  ocxObj.WebSetMsgByName("COMMAND","INSERTFILE");
  	   	if(ocxObj.WebLoadTemplate()){  
  	   	//增加防护，避免没有套红成功保存，原文件内容丢失问题
  	   	  ocxObj.WebSetMsgByName("CUROPERATE","TaoHong");
  			ocxObj.EditType="1,0";
  			ocxObj.EnableMenu(getOfficeLanguage("menu_PageSet"));
  			if(this.actionCanSign){
  				ocxObj.EnableMenu(getOfficeLanguage("menu_SginSeal"));
  			}
  			if(templateType == "edoc" && isFullSize){//正文套红才全显示,如果是文单套红就不需要全屏,不然会弹出2次
  				this.FullSize();
  			}
			setAllLable(dataForm,templateType,dataList,opinionArr);
			if(this.createDate){
				ocxObj.WebSetMsgByName("CREATEDATE", this.createDate);
			}
			ocxObj.WebSetMsgByName("needReadFile", "true");
			ocxObj.WebSetMsgByName("checkBack", "false");
			taohongLogo(ocxObj);
			
			//ocxObj.WebInsertFile();
			if(templateType=="edoc"){
				WebApplyRedHead(mObject);
			}
			//if(ocxObj.WebInsertFile()){ocxObj.WebSetMsgByName("CUROPERATE","");}		
			ocxObj.DisableMenu(getOfficeLanguage("menu_BrowseChar,menu_BrowseHandWrite,menu_HiddenTrail,menu_DisplayTrail"));
			if(this.hasPDF417Manager 
				&& typeof this.CopyRight 
				&& (ocxObj.FileType == ".doc" || ocxObj.FileType == ".docx") 
		    	&& (ocxObj.EditType == "1,0" || ocxObj.EditType == "2,0" || ocxObj.EditType == "3,0" || ocxObj.EditType == "2,1" || ocxObj.EditType == "1,1") || ocxObj.EditType == "3,1"){
		    	  	ocxObj.EnableMenu(getOfficeLanguage("menu_BarCode"));
		      }
			
		} 	
		//套红后，隐藏痕迹，设置痕迹控制菜单
  	  if(templateType=="edoc"){
  	   		ocxObj.WebSetRevision(false,false,false,this.isShowShenYueMenu);
  	   		this.enableRepairContent(ocxObj);
  	   		this.contentUpdate=true;	
  	   	}
		ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
    	ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));  
}
/*********************************************兼容老版本套红start************************************************************/
/**
 * 老版本公文文单套红
 */
HandWrite.prototype.oldTaohongForm=function(dataForm,templateUrl,templateType,dataList){
  this.checkOpenState();
  var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
  ocxObj.Template=templateUrl;
  ocxObj.WebSetMsgByName("COMMAND","INSERTFILE");
  	   	if(ocxObj.WebLoadTemplate()){  	
  			ocxObj.EditType="1,0";
			oldsetAllLable(dataForm,templateType,dataList);
			if(parent.createDate){
				ocxObj.WebSetMsgByName("CREATEDATE", parent.createDate);
			}
			ocxObj.WebSetMsgByName("needReadFile", "true");
			ocxObj.WebSetMsgByName("checkBack", "false");	
			taohongLogo(ocxObj);
			if(parent.createDate){
				ocxObj.WebSetMsgByName("CREATEDATE", parent.createDate);
			}
			ocxObj.WebSetMsgByName("needReadFile", "true");
			ocxObj.WebSetMsgByName("checkBack", "false");
			ocxObj.WebInsertFile();
			ocxObj.DisableMenu(getOfficeLanguage("menu_BrowseChar,menu_BrowseHandWrite,menu_HiddenTrail,menu_DisplayTrail"));
		} 	
		//套红后，隐藏痕迹，设置痕迹控制菜单
		ocxObj.WebSetRevision(false,true,false,this.isShowShenYueMenu);
		ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
    	ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));
}

/**
 * 老版本公文正文套红
 */
HandWrite.prototype.oldTaoHongEdocContent=function(dataForm,templateUrl,templateType,dataList){
	  this.checkOpenState();
	  var mObject = document.getElementById("WebOffice2015");
	  var ocxObj = mObject.FuncExtModule;
	  ocxObj.Template=templateUrl;
	  
	  ocxObj.WebSetMsgByName("COMMAND","INSERTFILE");
	  	   	if(ocxObj.WebLoadTemplate()){  
	  	   	//增加防护，避免没有套红成功保存，原文件内容丢失问题
	  	   	  ocxObj.WebSetMsgByName("CUROPERATE","TaoHong");
	  			ocxObj.EditType="1,0";
	  			ocxObj.EnableMenu(getOfficeLanguage("menu_PageSet"));
	  			this.FullSize();
	  			oldsetAllLable(dataForm,templateType,dataList);
				if(this.createDate){
					ocxObj.WebSetMsgByName("CREATEDATE", this.createDate);
				}
				ocxObj.WebSetMsgByName("needReadFile", "true");
				ocxObj.WebSetMsgByName("checkBack", "false");
				taohongLogo(ocxObj);
				
				WebApplyRedHead(mObject);
				ocxObj.DisableMenu(getOfficeLanguage("menu_BrowseChar,menu_BrowseHandWrite,menu_HiddenTrail,menu_DisplayTrail"));
				if(this.hasPDF417Manager 
					&& typeof this.CopyRight 
					&& (ocxObj.FileType == ".doc" || ocxObj.FileType == ".docx") 
			    	&& (ocxObj.EditType == "1,0" || ocxObj.EditType == "2,0" || ocxObj.EditType == "3,0" || ocxObj.EditType == "2,1" || ocxObj.EditType == "1,1") || ocxObj.EditType == "3,1"){
			    	  	ocxObj.EnableMenu(getOfficeLanguage("menu_BarCode"));
			      }
				
			} 	
			//套红后，隐藏痕迹，设置痕迹控制菜单
			ocxObj.WebSetRevision(false,false,false,this.isShowShenYueMenu);
			ocxObj.DisableMenu(getOfficeLanguage("menu_HiddenTrail"));
	    	ocxObj.EnableMenu(getOfficeLanguage("menu_DisplayTrail"));  
	    	this.enableRepairContent(ocxObj);
	  	    this.contentUpdate=true;	
	}
function oldsetAllLable(dataForm,templateType,dataList){
	try{
		for(var i = 0; i < dataList.length; i++){
			var name = dataList[i].name;
			var index = name.indexOf("my:");
			var label = name.substring(3,name.length);			
			if(index!=-1){
				try{oldsetLable(label,dataList[i].value);}catch(e){}				
			}
		}
	}catch(e){}
	var len = dataForm.elements.length;
	if(templateType=="edoc"){ // 正文套红
		for(var i=0;i<len;i++){
			var name = dataForm.elements[i].name;
			if(!name){
				continue;
			}
			var index = name.indexOf("my:");
			var label = name.substring(3,name.length);			
			if(index!=-1){
				if(label == "doc_mark" || label == "doc_mark2" || label == "serial_no"){
					try{
						var docMark = dataForm.elements[name].value;
						if (docMark.indexOf("|") != -1) {
							var docMarkArray = docMark.split("|");
							if(docMarkArray.length > 1){
								oldsetLable(label,docMarkArray[1]);
							}
						} else {
							oldsetLable(label,docMark);
						}
						continue;
					}catch(e){}					
				}
				var tagName = dataForm.elements[name].tagName;
				if(tagName !="undefined" && (tagName == "SELECT" || tagName == "select")){
					if(label == "doc_mark"){
							try{
								var docMark = dataForm.elements[name].value;
								var docMarkArray = docMark.split("|");
								if(docMarkArray.length > 1){
									oldsetLable(label,docMarkArray[1]);
								}
							}catch(e){}					
					}else{
						var select = dataForm.elements[i];
						for(var j=0;j<select.options.length;j++)
						{
							if(select.options[j].selected == true){
								try{oldsetLable(label,select.options[j].text);}catch(e){}								
							}
						}
	
					}			
				}else{
					try{
						var rvalue = dataForm.elements[name].getAttribute("rvalue");
						if(typeof(rvalue) != "undefined" && rvalue != null && rvalue != ""){
							oldsetLable(label,rvalue);
						}else{
							oldsetLable(label,dataForm.elements[name].value);
						}
						
					}catch(e){}		
				}
			}
		}
	}
	else{ // 文单套红
		for(var i=0;i<len;i++){
			var name = dataForm.elements[i].name;
			var index = name.indexOf("my:");
			var label = name.substring(3,name.length);			
				if(index!=-1){
					//孙老师意见：文单套红只是不套正文的内容，其他的都要套。
					if(label=="Content"){
						continue;
					}
					if(label == "doc_mark" || label == "doc_mark2" || label == "serial_no"){
						try{
							var docMark = dataForm.elements[name].value;
							if (docMark.indexOf("|") != -1) {
								var docMarkArray = docMark.split("|");
								if(docMarkArray.length > 1){
									oldsetLable(label,docMarkArray[1]);
								}
							} else {
								oldsetLable(label,docMark);
							}
							continue;
						}catch(e){}					
					}
					var tagName = dataForm.elements[name].tagName;
					if(tagName !="undefined" && (tagName == "SELECT" || tagName == "select")) {
						var select = dataForm.elements[i];
						for(var j=0;j<select.options.length;j++){
							if(select.options[j].selected == true){
								try{oldsetLable(label,select.options[j].text);}catch(e){}								
							}
						}
					}else{
						try{
							var rvalue = dataForm.elements[name].getAttribute("rvalue");
							if(typeof(rvalue) != "undefined" && rvalue != null && rvalue != ""){
								oldsetLable(label,rvalue);
							}else{
								oldsetLable(label,dataForm.elements[name].value);
							}
							
						}catch(e){}
					}
				}		
			}
		}	
	    taohongOpinionOld(templateType);
}

//套红意见。
function taohongOpinionOld(type){
	try{
		var  opinionArr = parent.getOpinionsForTaoHong(type); 
		var opinions = opinionArr[0];
		var senderOpinion = opinionArr[1];
		if(opinions){
			for(var i=0 ;i<opinions.length ; i++){
				oldsetLable(opinions[i][0],opinions[i][1].replace(/(\n)+|(\r\n)+/g, "\r\n"));
			}
		}
		if(senderOpinion){
			oldsetLable("niwen",senderOpinion);
			oldsetLable("dengji",senderOpinion);
		}
	}catch(e){
		
	}
}

function oldsetLable(mylable,mycontent){  
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	if(mylable.search("date")!=-1){//名称中包括了data就为date数据类型
		if(mylable=="signing_date"){//签发日期根据公文开关转化为大小写。
			var isSwitch=false;
			if(parent.contentIframe){
				var sendForm = parent.contentIframe.document.getElementById("sendForm");
				if(sendForm.taohongriqiSwitch && sendForm.taohongriqiSwitch.value=="true") {
					isSwitch=true;
				}
			}else{
				var taohongSwitchObj=parent.document.getElementById("taohongriqiSwitch");
				if(taohongSwitchObj){
					if(taohongSwitchObj.value && taohongSwitchObj.value=="true") {
						isSwitch=true;
				   	}
			    }
			}
			if(isSwitch){
				mycontent=parent.date2chinese0(mycontent);
			}else{
				mycontent=parent.date2chinese1(mycontent);
			}
		}else{
			mycontent=parent.date2chinese1(mycontent);
		}
	}
	//套红时发文单位显示格式
	if(mylable.search("send_unit")!=-1) {
		if(parent.contentIframe) {
			var sendForm = parent.contentIframe.document.getElementById("sendForm");
			if(sendForm.taohongSendUnitType && sendForm.taohongSendUnitType.value==1) {
				var sendUnitName = parent.getSendUnitName(mylable);
				if(sendUnitName!=null && sendUnitName!="") {
					mycontent = sendUnitName;
				}
			}			
		}
	}
	
  	try{
  		ocxObj.WebSetBookMarks(mylable,mycontent);
  	}catch(e){
  		alert(e);
  	}
}
/*********************************************兼容老版本套红end************************************************************/
function setAllLable(dataForm,templateType,dataList,opinionArr){
	if(templateType=="edoc"){ // 正文套红
		edocTaoHong(dataForm,templateType,dataList,false);
	}else{ // 文单套红
		edocTaoHong(dataForm,templateType,dataList,true);
	}
	taohongOpinion(templateType,opinionArr);
}

var isAlertProtectFile = false;
function edocTaoHong(dataForm,templateType,dataList,isOrNotEdoc){
	isAlertProtectFile = false;//正文盖章后，套红时，弹出提示语“不允许您编辑此内容，因为它受保护”，这个变量用于是否弹出这个提示语
	var allData = dataForm.find("[id^=field]");
	for(var i=0;i<allData.length;i++){
		var oneData = allData[i];
		var label = oneData.getAttribute("mappingField");
		var dataValue = oneData.getAttribute("text");
		if(undefined == dataValue || null == dataValue || "" == dataValue){
			dataValue = oneData.value;
		}
		if(undefined == dataValue || null == dataValue || "" == dataValue){
			dataValue = oneData.innerText;
		}
		// 公文模板中绑定套红模板，拟文时提示是否自动更新文单中书签内容，点取消，只更新一部分书签
		if(undefined == dataValue || null == dataValue || "" == dataValue){
			var child = oneData.childNodes;
			if(child!=null&&child.length>0){
				var inputNode = child.item(0);
				var tagN = inputNode.nodeName;
				if(tagN !="undefined" && (tagN == "INPUT" || tagN == "inputs")){
					dataValue = inputNode.value;
				}
			}
		}
		var fieldVal = oneData.getAttribute("fieldVal");
		var comp = oneData.getAttribute("comp");
		var editData = oneData.children.item(0);

		if(undefined!=comp){
			try{
			comp = eval('({' + comp + '})');
			}catch(e){}
		}

		if(undefined!=fieldVal){
			fieldVal = eval('(' + fieldVal + ')');
		}
		if(undefined != label){
			if(isOrNotEdoc){
			//文单套红只是不套正文的内容，其他的都要套。
				if(label=="Content"){
					continue;
				}
			}
		}

		var tagN = oneData.nodeName;
		if(tagN !="undefined" && (tagN == "INPUT" || tagN == "inputs")){
			var parentData = oneData.parentNode.parentNode;
			if("undefined"!=parentData&&(parentData.nodeName=="SPAN"||parentData.nodeName=="span")){//如果是编辑状态的意见
				var f = parentData.getAttribute("fieldVal");
				if("undefined"!=f&&null!=f){
					f = eval('('+f+')');
					if(f.inputType=='edocflowdealoption'){
						continue;
					}
				}
			}
		}
		if(tagN !="undefined" && (tagN == "SELECT" || tagN == "select")){
			var index = oneData.selectedIndex;
			if(typeof(index) != "undefined" && oneData.options[index]){
				dataValue = oneData.options[index].text;
			}
			if(label == 'serial_no'){ //当内部文号为空时不设置书签
				if(dataValue == '请选择内部文号' || dataValue == '請選擇內部文號' || dataValue == 'please choose innser mark'){
					dataValue = "";
				}else{
					dataValue = oneData.value;
				}
			}
			if(label == 'doc_mark'){//当来文文号为空时不设置书签
				if(dataValue == '请选择机构代字' || dataValue == '請選擇機構代字' || dataValue == 'please choose mark'){
					dataValue = "";
				}else{
					dataValue = oneData.value;
				}
			}
		}
		if(undefined!=fieldVal){
			if(undefined==label){
				label = fieldVal.name;
			}
			if(undefined!=editData){
				var tagName = editData.nodeName;
				if(tagName !="undefined" && (tagName == "SELECT" || tagName == "select") || (fieldVal.inputType == "SElECT" || fieldVal.inputType == "select")){
					var index = editData.selectedIndex;
					if(typeof(index) != "undefined" && editData.options[index]){
						dataValue = editData.options[index].text;
					}
				}
				if(fieldVal.inputType=='edocflowdealoption'&&tagName !="undefined" && (tagName == "DIV" || tagName == "div")){
					var a = editData.innerText;
					a   =   a.replace(/\s+/g,"");
					if(a==""){
						dataValue="";
					}
				}
				if(fieldVal.fieldType=='TIMESTAMP'&&tagName !="undefined" && (tagName == "INPUT" || tagName == "input")){
					dataValue = editData.getAttribute("value");
				}
				if((fieldVal.inputType=='member'||fieldVal.inputType=='account'||fieldVal.inputType=='department'||fieldVal.inputType=='post')&&tagName !="undefined" && (tagName == "INPUT" || tagName == "input")){

					dataValue = editData.getAttribute("title");
				}
				if(fieldVal.inputType=='edocDocMark'||fieldVal.inputType=='edocInnerMark'){
					editData = oneData.children.item(0);
					if(undefined != editData && null != editData){
						if(undefined!=editData&&(tagName=="SELECT"||tagName=='select')){
							var index = editData.selectedIndex;
							if(index && undefined != editData.options[index] && null != editData.options[index]) {
								dataValue = editData.options[index].value;
								if(dataValue && dataValue != ""){
									var a = dataValue.split("|");
									if(a.length > 1){
										dataValue = a[1];
									}
								}
							}
						}
					}
				}
				if(editData.getAttribute("type") =='checkbox'&&tagName !="undefined" && (tagName == "INPUT" || tagName == "input")){
					if(editData.getAttribute("newValue")=='1'){
						dataValue=editData.getAttribute("newDisplay");
					}else if(editData.getAttribute("newValue")=='0'){
						dataValue="";
					}
				}
				//添加radio 控件
				if(fieldVal.inputType=='radio'){
					var nodeHtml =  oneData.childNodes;
					//先置为空，有选中则赋值，反之则为空
					dataValue="";
					for(var p=0;p<nodeHtml.length;p++){
						try {
							if(nodeHtml[p].document.getElementsByTagName("input")[p].checked){
								dataValue = nodeHtml[p-1].innerText;
								break;
							}
						} catch(e) {
							//兼容IE11
							try {
								var inputs = nodeHtml[p].childNodes;
								if((inputs[0].nodeName == "input"||inputs[0].nodeName == "INPUT")
										&& (inputs[0].getAttribute("checked")=="true"||inputs[0].checked||inputs[0].checked=='true')) {
									dataValue = nodeHtml[p].innerText;
									break;
								}
							} catch(e) {}
						}
					}
				}
				if(fieldVal.inputType=="attachment"){
					var attsarr = new Array();
					getA8Top().$(oneData).find("div[id^='attachmentDiv_']").each(function(){
						attsarr.push(getA8Top().$(this).text().replace(/^[\s　]+|[\s　]+$/g,''));
					});
					dataValue=attsarr.join("\n");
				}
			}
		}else{
			if(oneData.getAttribute("type") == 'checkbox'){
				if(oneData.getAttribute("newValue")=='1'){
					label = oneData.id;
					dataValue=oneData.getAttribute("newDisplay");
				}else if(oneData.getAttribute("newValue")=='0'){
					label = oneData.id;
					dataValue="";
				}
			}
		}
		
		//除签收日期外，其他日期要根据文单设置的显示方法进行显示(可编辑状态下有问题)
		if(label && label.search("date")!=-1 && label!="signing_date"){
			var fieldTxt = oneData.id;
			if(fieldTxt){
				var inputDate = dataForm.find("[id="+fieldTxt+"_txt]");
				if(inputDate && inputDate.length > 0 && inputDate[0].value){
					dataValue = inputDate[0].value;
				}
			}
			
		}
		
		//意见无法换行，获取对于id_span的内容才可显示换行
		if(undefined!=comp && comp.type=='edocFlowOpinion' && dataValue && dataValue.indexOf("\r\n") == -1){
			var optionSpan = dataForm.find("[id="+oneData.id+"_span]");
			if(optionSpan && optionSpan.length > 0 && optionSpan[0].innerText){
				dataValue = optionSpan[0].innerText;
			}
		}

		//}
		if(undefined != dataValue && null != dataValue && '' !=dataValue){
			//文单套红，套出来的附件名称之间空格太多
			if(templateType=="script" && label == 'attachments'){
				var atts = dataValue.split("\r\n");
				var txt = "";
				for (var n=0;n<atts.length ;n++) {
					if(atts[n] == ''){
						continue;
					}
					if(txt.length > 0){
						txt = txt + "\r\n";
					}
					txt = txt + atts[n];
				}
				dataValue = txt;
			}
			try{setLable(label,dataValue);}catch(e){}
		}
	}
}
//套红意见。
function taohongOpinion(type,opinionArr){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	try{

		var opinions = opinionArr[0];
		var senderOpinion = opinionArr[1];
		if(opinions){
			// 意见套红套入签章与签批图片   开始
			for(var i=0 ;i<opinions.length ; i++){
				var content = "";
				var imgArr = new Array();
				for(var j=1;j<opinions[i].length;j++){
					if(opinions[i][j].indexOf("id=")!=-1){
						content = content +"\r\nimg";//img 为图片的占位符
						imgArr.push(opinions[i][j].split("=")[1]);
					}else if(opinions[i][j].indexOf("writeGIF")!=-1){
						content = content +"\r\nimg";
						imgArr.push(opinions[i][j]);
					}else{
						content = content+opinions[i][j];
					}
				}
				var img = new Array();
				//反转数组
				for(var j=imgArr.length-1;j>=0;j--){
					img.push(imgArr[j]);
				}
				var ta = content.split("img");//
				var index = 0;//图片数组下标
				var item = null;
				var myRange = null;
				var c = 0;//书签下标
				
                //反向插入  正向插入  意见元素是倒向的
				for (var j = ta.length - 1; j >= 0; j--) {
					// 插入文字
					try{
						//更新书签时需要清空意见区域原有内容
						setLable("sign" + i + c," ");
						setEdocSignetLable("sign" + i + (c+1), " ");
						
						if(myRange == null){
							//win7 wps2016会将意见元素删除，故用下面的兼容处理
							if(ocxObj.WebObject.Bookmarks.Exists(opinions[i][0])){
								//去掉公文元素意见对应书签的内容
								setLable(opinions[i][0],"");
								item = ocxObj.WebObject.Application.ActiveDocument.Bookmarks.item(opinions[i][0]);//每次取出来的Range  item.End坐标不一样
								myRange = ocxObj.WebObject.Range(item.End, item.End);// 获取当前书签的Range
							}else{
								continue;
							}
							//else{
								//item = ocxObj.WebObject.Application.ActiveDocument.Bookmarks.item("sign"+i+"0");
								//myRange = ocxObj.WebObject.Range(item.Start, item.Start);
							//}
							
						}
						
						ocxObj.WebObject.Application.Selection.Bookmarks.Add("sign"
								+ i + c, myRange);//动态生成书签名称  并插入文档
						setLable("sign" + i + c, ta[j]);
						
						item = ocxObj.WebObject.Application.ActiveDocument.Bookmarks.item("sign" + i + c);
						myRange = ocxObj.WebObject.Range(item.Start, item.Start);
						c++;
						// 插入图片
						ocxObj.WebObject.Application.Selection.Bookmarks.Add("sign"
								+ i + c, myRange);
						
						// 如果有书签才进行套红
						if (ocxObj.WebObject.BookMarks.Exists("sign" + i + c)) {
							setEdocSignetLable("sign" + i + c, img[index++]);
						}
						
						item = ocxObj.WebObject.Application.ActiveDocument.Bookmarks.item("sign" + i + c);
						myRange = ocxObj.WebObject.Range(item.Start, item.Start);
						c++;
					}catch(e){}
				}
			}
			//意见套红套入签章与签批图片  结束
		}
		if(senderOpinion){
			setLable("niwen",senderOpinion);
			setLable("dengji",senderOpinion);
		}
	}catch(e){

	}
}

//意见套红套入签章与签批图片
function setEdocSignetLable(lable,image){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	try{var re = ocxObj.WebInsertImage(lable,image,true,3);}catch(e){if(!isAlertProtectFile){isAlertProtectFile=true;}}
}

HandWrite.prototype.setLable4Magazine=function(mylable,mycontent){
	setLable(mylable,mycontent);
}

function setLable(mylable,mycontent){  
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	if(mylable.search("date")!=-1)
	{//名称中包括了data就为date数据类型
		if(mycontent) {
			mycontent = lrtrim(mycontent);
		}
		if(mylable=="signing_date"){//签发日期根据公文开关转化为大小写。
			//时间值为空的，不进行转换
			if(mycontent && mycontent != ""){
				if(handWriteObj.extendParams.isSwitch){
					if(mycontent.indexOf("年")!=-1){
						mycontent = mycontent.replace("年","-");
						mycontent = mycontent.replace("月","-");
						mycontent = mycontent.replace("日","");
					}
					mycontent=handWriteObj.extendParams.date2chinese0(mycontent);
				}else{
					if(mycontent.indexOf("年")==-1){
						mycontent=handWriteObj.extendParams.date2chinese1(mycontent);
					}
				}
			}
		}else{
			//580专版新加公文元素，因为是日期时间型。这里单独处理
			if(mylable=="send_date"){
				if(mycontent && mycontent != ""){
					var ns=mycontent.split("-");
					if(ns.length==3){
						mycontent = mycontent.replace("-","年");
						mycontent = mycontent.replace("-","月");
						mycontent = mycontent.replace(" ","日");
					}
				}
			}else{
				mycontent=handWriteObj.extendParams.date2chinese1(mycontent);
			}
		}
	}

  	try{ocxObj.WebSetBookmarks(mylable,mycontent);}catch(e){if(!isAlertProtectFile){isAlertProtectFile=true;}}
}
HandWrite.prototype.officePrint=function(){
	if(!this.isHandWriteRef()){
		return false;
	}
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	this.checkOpenState();
	this.FullSize();
	window.setTimeout(function(){
		
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		ocxObj.WebOpenPrint();	
	}, 300);
	return true;
}

HandWrite.prototype.setOfficeOcxRecordID=function(recordId){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	ocxObj.RecordID=recordId;
	this.contentId=recordId;
	this.isLoadOfficeFile=false;
	this.wordTextContent="";
}

HandWrite.prototype.getOfficeOcxRecordID=function(){
//	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;	
	return this.fileId;	
}
//得到控件当前版本ID
HandWrite.prototype.getOfficeOcxCurVerRecordID=function(){
	if(this.curMenuID>200){//当前为清稿备份版本
		return this.curDataID;
	}else{
//		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;	
		return this.fileId;	
	}
}

////////////////////////////////////////如下代码为判断控件是否保护代码////////////////////////////////////////////////


//作用：判断Excel是否有未选择锁定的单元格
function HasNoLockedRangeXls(ocxObj){
  if(ocxObj.WebObject.ActiveSheet.UsedRange.Locked==true){
  	return true;   //存在单元格锁定
  }else{
    return false;  //无单元格锁定
  }
}

//判断是否是用户进行了保护,设置了自己的密码
function isUserOfficeProtection(ocxObj){
	var ret=false;
	try{	
		if(IsOfficeProtection(ocxObj)==0){
			return false;
		}
		ocxObj.WebSetProtect(false,"");
		var proState=IsOfficeProtection(ocxObj);
		if(proState!=0)
		{//用户设置了密码,解锁失败
			return true;
		}
		ocxObj.WebSetProtect(true,"");
	}catch(e){}
	return ret;
}

//作用：判断当前OFFICE文档保护状态
function IsOfficeProtection(ocxObj){
    var mIsProtection = 0;  //无锁定
    try{
    if (ocxObj.FileType==".doc" || ocxObj.FileType==".docx"  || ocxObj.FileType==".wps"){
      if (ocxObj.WebObject.ProtectionType!=-1){  //表示当前DOC文档有锁定
      	mIsProtection = 1;  //全部锁定
      }
    }
    if (ocxObj.FileType==".xls" || ocxObj.FileType==".xlsx"){
      if (HasNoLockedRangeXls(ocxObj)){
      	if (ocxObj.WebObject.ActiveSheet.ProtectScenarios||ocxObj.WebObject.ActiveSheet.ProtectContents||ocxObj.WebObject.ActiveSheet.ProtectDrawingObjects){
      		mIsProtection = 2;  //部分锁定
      	}else{
      	  mIsProtection = 0;  //无锁定
      	}
      }else{
      	if (ocxObj.WebObject.ActiveSheet.ProtectScenarios||ocxObj.WebObject.ActiveSheet.ProtectContents||ocxObj.WebObject.ActiveSheet.ProtectDrawingObjects){
      		mIsProtection = 1;  //全部锁定
      	}else{
      	  mIsProtection = 0;  //无锁定
      	}    
      }
    }
    else if(ocxObj.FileType==".et"){
      mIsProtection=IsEtProtection(ocxObj);
    }
    }catch(e){}
    return (mIsProtection);
}
//作用：判断当前金山表格文档保护状态
function IsEtProtection(ocxObj){
    var mIsProtection = 0;  //无锁定
    if (ocxObj.FileType==".et"){
      if(ocxObj.WebObject.ActiveSheet.UsedRange.Locked==9999999){
      	if (ocxObj.WebObject.ActiveSheet.ProtectContents){
      		mIsProtection = 2;  //部分锁定
      	}else{
      	  mIsProtection = 0;  //无锁定
      	}
      }else{
      	if (ocxObj.WebObject.ActiveSheet.ProtectContents){
      		mIsProtection = 1;  //全部锁定
      	}else{
      	  mIsProtection = 0;  //无锁定
      	}    
      }
    }
    //alert(mIsProtection);
    return (mIsProtection);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/**
设置所有菜单的显示状态,false 隐藏 true 显示
**/
function setAllToolsState(ocxObj,state){
try{
  ocxObj.ShowMenu="1";
  ocxObj.WebToolsVisible('Tables and Borders',state);//表格和边框
  ocxObj.WebToolsVisible('Database',state);// 数据库
  ocxObj.WebToolsVisible('Drawing',state);//绘图
  ocxObj.WebToolsVisible('Forms',state);//窗体
  ocxObj.WebToolsVisible('Visual Basic',false);// isual Basic
  ocxObj.WebToolsVisible('Mail Merge',state);// 合并
  ocxObj.WebToolsVisible('Extended Formatting',state);//其它格式
  ocxObj.WebToolsVisible('AutoText',state);//自动图文集
  ocxObj.WebToolsVisible('Web',state);//Web
  ocxObj.WebToolsVisible('Picture',state);//图片
  ocxObj.WebToolsVisible('Control Toolbox',state);//控件工具箱
  ocxObj.WebToolsVisible('Web Tools',state);//Web工具箱
  ocxObj.WebToolsVisible('Standard',false);//标准
  ocxObj.WebToolsVisible('Formatting',false);//格式
  ocxObj.WebToolsVisible('Reviewing',false);//审阅
  ocxObj.WebToolsVisible('Frames',false);//框架集
  ocxObj.WebToolsVisible('WordArt',false);//艺术字
  ocxObj.WebToolsVisible('符号栏',false);//符号栏
  ocxObj.WebToolsVisible('Outlining',false);// 大纲
  ocxObj.WebToolsVisible('E-mail',false);//电子邮件
  ocxObj.WebToolsVisible('Word Count',false);//字数统计
  try{
	  webform.WebOffice.ToolsSpace="0";
  }catch(e){}//隐藏菜单下面开始无法隐藏的灰色挑
  }catch(ea){
	  var errStr=ea.number & 0xFFFF;
	  errStr=errStr+":"+ea.description;
	  alert(errStr);
  }
}

//作用：禁止或启用工具 参数1表示工具条名称  参数2表示工具条铵钮的编号  （名称和编号均可查找VBA帮助）
//参数3为false时，表示禁止  参数3为true时，表示启用
function WebToolsEnable(ocxObj,ToolName,ToolIndex,Enable){
  try{
    ocxObj.WebToolsEnable(ToolName,ToolIndex,Enable);    
  }catch(e){}
}

function WebToolsPrintState(ocxObj,Enable){
    try{
        if (ocxObj.FileType==".doc"|| ocxObj.FileType==".docx" ||ocxObj.FileType==".xls" || ocxObj.FileType==".xlsx" ){
        	WebToolsEnable(ocxObj,'Standard',2521,Enable);  //屏蔽打印铵钮
        	WebToolsEnable(ocxObj,'Standard',108,Enable);  //屏蔽打印预览按钮
      	}
      	if ((ocxObj.FileType==".wps")||(ocxObj.FileType==".et")){
      	    try{
        	   ocxObj.WebObject.Application.CommandBars("Standard").Controls("打印").Enabled = Enable;  //屏蔽打印铵钮
        	   ocxObj.WebObject.Application.CommandBars("Standard").Controls("打印预览(&V)").Enabled = Enable;  //屏蔽打印铵钮
      	    }catch(e){}
      	}
      	ocxObj.Print=Enable;
  	}catch(e){}
}

HandWrite.prototype.contentIsModify=function(){
	if(this.isLoadOfficeFile == false){
		return false;
	}
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	if(ocxObj.EditType=="0,0"){
		return false;
	}
	//没有盖章的时候，状态为4,0的时候，返回false，表示没有修改正文。
	if(ocxObj.EditType=="4,0"&&!handWriteObj.isSignOperation) {
		return false;
	}
	ocxObj.Active(true);//使控件获取焦点，这样判断更准确
	return ocxObj.Modify;
}

HandWrite.prototype.setToolsPrintState=function(ocxObj){
	  //根据页面设置控制菜单	  
      if(this.officecanPrint=="false")
      {
      	ocxObj.DisableMenu(getOfficeLanguage("menu_Print"));
      	ocxObj.DisableMenu(getOfficeLanguage("menu_PrintPreview"));
      	WebToolsPrintState(ocxObj,false);
      }
       if(this.officecanSaveLocal=="false"){	
          	ocxObj.DisableMenu(getOfficeLanguage("menu_SaveFile"));
      }
}
//判断是否有印章或签名
HandWrite.prototype.getSignatureCount=function(sign){
  var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
  this.checkOpenState();
  if(sign != true || sign != false){
	  sign = true;
  }
  var count = false;
  try{
	  count=ocxObj.SignatureCount(sign)>0;
  }catch(e){}
  return count;
}
/**
 *是否有专业签章、
 */
HandWrite.prototype.HasSpecialSignature=function(ocxObj){
  if(!ocxObj){
	  ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
  }
  var i,Shape;
  var Result = false;
  try{
	  var shapes = ocxObj.WebObject.Shapes;
	  if(shapes == undefined){
		  return Result;
	  }
      for(i=1;i<= shapes.Count;i++){
        Shape = shapes.Item(i);
        if(Shape.Type == 12){
          if(Shape.OLEFormat.ClassType == "iSignatureOffice.SignatureCtrl"){
            Result = true;
            break;
          }
        }else if(Shape.Type == 6){ //iSignature_WPS混合_HTML签章
			if(Shape.GroupItems.Count==4||Shape.GroupItems.Count==5||Shape.GroupItems.Count==7){
				if(Shape.GroupItems.Item(2).Type==13&&Shape.GroupItems.Item(3).Type==13&&Shape.GroupItems.Item(4).Type==13){
					Result = true;
					break;
				}
			}
		}else if(Shape.Type == 13 && Shape.name && Shape.name.substring(0,3)=="KG_"){
			Result = true;
			break;
		}
      }
  }catch(e){}
  return Result;
}
var isAlert = false;
//如果不安装就引用不了。这里是引用的判断。
HandWrite.prototype.isHandWriteRef=function(isAlert){
	try{
		if(handWriteObj.updateOcx){
			if(handWriteObj.initOfficeErrorCallback!=null && typeof(handWriteObj.initOfficeErrorCallback)!="undefined"){
				handWriteObj.initOfficeErrorCallback();
			}
			return false;
		}
	}catch(e){}
	
	var status=true;
	try{
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;

		if(ocxObj == null){
			status = false;
		}
        else{

			var browser = new Browser();
			if(browser.isMSIE || browser.isChrome){
				status = handWriteObj.checkVersion();
				if(!status){//这里status=false表示已经弹出提示强制更新的窗口了，不在弹出office不可用的提示
					isAlert = false;
				}
			}else{
				ocxObj.WebGetMsgByName("needReadFile");
			}
		}
		
	}catch(e){
		//报异常就是没有引用的意思。
		status = false;
	}
	if(!status){
		isAlert = typeof(isAlert) == 'undefined' ? true : isAlert;
		if(isAlert){
			//代码合并有误，解决office提示不断提出，应该使用以下方式
			alert(getOfficeLanguage("alert_err_HandWrite_Disbaled"));
		}
		if(handWriteObj.initOfficeErrorCallback!=null){
			handWriteObj.initOfficeErrorCallback();
		}
	}
	return status;
}

function Browser(){
	try{
		var ua = navigator.userAgent;
		this.isMSIE = (navigator.appName == "Microsoft Internet Explorer")||ua.indexOf('Trident')!=-1;
		this.isChrome = ua.indexOf('Chrome') != -1;
	}catch(e){}
}

//校验控件版本
HandWrite.prototype.checkVersion=function(){
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxHandWriteManager", "ajaxGetOfficeVersion",false);
	var ds = requestCaller.serviceRequest();
	try{
		var ocxObj = document.getElementById("WebOffice2015");
		if(ds && ds != ocxObj.Version && _checkVersion(ds,ocxObj.Version)){
			dialog(this.webRoot);
			return false;
		}
	}catch(e){
		dialog(handWriteObj.webRoot);
		return false;
	}
	
	return true;
}

//return true 服务器版本高于客户端版本
function _checkVersion(sver,cver){
	var state = false;
	if(sver && cver){
		var _sver = sver.replace(/\./g, '');
		var _cver = cver.replace(/\./g, '');
		if(parseInt(_sver) > parseInt(_cver)){
			state = true;
		}
	}else{
		state = true;
	}
	return state;
}

function dialog(webRoot){
	handWriteObj.updateOcx = true;
	var locale = getOfficeLanguage("office_locale");
	var options = {
        url : webRoot + "/common/office/checkOfficeVersion.html?locale="+locale,
        title : getOfficeLanguage("office_update"),
        width : 500,
        height : 240,
        targetWindow : top
    };
	if(top.layer){
		options.closeParam={
			'show':true,
			autoClose:false,
			handler:function(){
				handWriteObj.updateOcx = false;
				if(handWriteObj.initOfficeErrorCallback!=null){
					handWriteObj.initOfficeErrorCallback();
				}
			}
		};
		top.layer.open(options);
	}else{
		getA8Top().v3x.openDialog(options);
	}
	
	var office2015 = document.getElementById("WebOffice2015");
	office2015.setAttribute("style","width:0px;height:0px;display:none;");
}
//删除文档中所有书签
HandWrite.prototype.delBookMarks=function(){
	try{
		var ocxObj = document.getElementById("WebOffice2015");
		var mCount = ocxObj.Activedocument.Bookmarks.Count;
		for(i=1;i<mCount+1;i++){
			ocxObj.Activedocument.Bookmarks(1).Delete();
		}
	}catch(e){
		
	}
}
/**
 * 激活office控件.
 */
HandWrite.prototype.activeOcx=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	if(ocxObj!= null){
		try{
			ocxObj.Active(true);
		}catch(e){
			
		}
	}
}

HandWrite.prototype.transAttribute=function(canEdit,canCopy,hasTrail){
	try{
		if(canEdit == true || canEdit == "true"){
			canEdit = "1";
		}
		if(canEdit == false || canEdit == "false"){
			canEdit = "0";
		}
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		  var result,type;
		  if(ocxObj){
		    type = ocxObj.EditType;
		  }else{
		    type ="0,0";
		  }
		  if(this.editType != null){
			  return this.editType;
		  }
		  if(typeof(type)=="undefined"){
			  return this.editType;
		  }
		  var arr = type.split(",");
		  if(arr){
		    if(canEdit == "0" && canCopy == "0"){
		      arr[0] = "0";
		    }else if(canEdit == "0" &&  canCopy == "1"){
		      arr[0] = "4";
		    }else if(canEdit == "1"){
		      arr[0] = "1";
		    } 
		    if(typeof(hasTrail)!="undefined"&&(hasTrail == "0" || hasTrail == "1")){
		      arr[1] = hasTrail;
		    }else{
		      arr[1] = 0;	
		    }
		    result = arr[0] + "," + arr[1];
		    if(ocxObj){
		      ocxObj.EditType = result;
		    }
		  }
		  this.editType = result;
	}catch(e){}
}

/**
 * templateUrl  套红模板地址 
 * bookMarkName	书签名称
 * jsonData     信息的json数据源
 */
HandWrite.prototype.doLoadFile=function(dataForm,templateUrl,bookMarkName,jsonData){
	this.checkOpenState();
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	ocxObj.Template=templateUrl;	  
	//增加防护，避免没有套红成功保存，原文件内容丢失问题
	if(dataForm != null){
		ocxObj.WebSetMsgByName("CUROPERATE","TaoHong");
	}
	ocxObj.WebSetMsgByName("COMMAND","INSERTFILE");
	var ret;
	if (ocxObj.WebLoadTemplate()) {
		ocxObj.EditType = "1,0";
		if(jsonData != null){
			if(typeof  FullSize=="function"){
				window.setTimeout("FullSize()", 10);
			}
			setInfoMagazineLable(dataForm);
			resolveMagazineTemplate(ocxObj,jsonData);
			ocxObj.WebSetMsgByName("CUROPERATE","");
		}else {
			ret=ocxObj.WebInsertFile();
		}
	}
	return ret;
}

function setInfoMagazineLable(dataForm){
	var len = dataForm.elements.length;
	for(var i=0;i<len;i++){
		var name = dataForm.elements[i].name;
		var taohongAttr = dataForm.elements[i].attributes["_taohong"];
		if(!name || !taohongAttr || taohongAttr.value.toLocaleLowerCase() != "true")continue;
		var label = name;
		//if(label == "magazine_no" || label == "publish_account" || label == "publish_time"){
			var docMark = dataForm.elements[name].value;
			setLable(label,docMark);
		//}
	}
}

function resolveMagazineTemplate(ocxObj,jsonData){
	ocxObj=document.getElementById("WebOffice2015");
	var mCount = ocxObj.Activedocument.Bookmarks.Count;
	var marksMaps = new Properties();
	if(typeof(ocxObj.Activedocument.BookMarksList)!='undefined'){
		var marksNamesStr = ocxObj.Activedocument.BookMarksList();
		var marksNames = marksNamesStr.split(";");
		for(var i=0;i<mCount;i++){
			var markname=marksNames[i];
			if(markname != "magazine_no" && markname != "publish_account" && markname != "publish_time"){
				marksMaps.put(markname,markname);
			}
		}
	}else{
		//alert(getOfficeLanguage("alert_low_OcxVer"));
		for(var i=1;i<mCount+1;i++){
			var markname=ocxObj.Activedocument.Bookmarks.Item(i).Name;
			if(markname != "magazine_no" && markname != "publish_account" && markname != "publish_time"){
				marksMaps.put(markname,markname);
			}
		}
	}
	
	var index = 1;
	var other_index = 1;
	for(var p in jsonData){ 
		var category_index = "category"+index;
		var other_category = "other_category";
		var other_info_subject = "other_info"+other_index+"_subject";
		var other_info_content = "other_info"+other_index+"_content";
		
		var other_info_reporter = "other_info"+other_index+"_reporter";
		var other_info_reportDept = "other_info"+other_index+"_reportDept";
		var other_info_reportUnit = "other_info"+other_index+"_reportUnit";
		
		var isNormal = false;
		if(marksMaps.containsKey(category_index)){
			setLable(category_index,jsonData[p][0].categoryName);
			marksMaps.remove(category_index);
		}
		for(var j=0; j<jsonData[p].length; j++){
			var subject_index = category_index+"_"+"info"+(j+1)+"_subject";
			var content_index = category_index+"_"+"info"+(j+1)+"_content";
			var reporter_index = category_index+"_"+"info"+(j+1)+"_reporter";
			var reportDept_index = category_index+"_"+"info"+(j+1)+"_reportDept";
			var reportUnit_index = category_index+"_"+"info"+(j+1)+"_reportUnit";
			
			if(marksMaps.containsKey(subject_index) && marksMaps.containsKey(content_index)){
				isNormal = true;
				if(jsonData[p][j].formContent !== ""){
					setLable(content_index,jsonData[p][j].formContent);
				}else {
					if(jsonData[p][j].infoFolder){
						if(content_index){
							ocxObj.FuncExtModule.WebSetMsgByName("bookMarkName", content_index);//要插入的书签
						}
						if(jsonData[p][j].infoFolder){
							ocxObj.FuncExtModule.WebSetMsgByName("fileUrl", jsonData[p][j].infoFolder);//待插入的文件路径
						}
						ret=ocxObj.FuncExtModule.WebInsertFile();//插入文件操作
					}
				}
				
				if(marksMaps.containsKey(reporter_index)){
					setLable(reporter_index,jsonData[p][j].reporter);
					marksMaps.remove(reporter_index);
				}
				
				if(marksMaps.containsKey(reportDept_index)){
					setLable(reportDept_index,jsonData[p][j].reportDept);
					marksMaps.remove(reportDept_index);
				}
				
				if(marksMaps.containsKey(reportUnit_index)){
					setLable(reportUnit_index,jsonData[p][j].reportUnit);
					marksMaps.remove(reportUnit_index);
				}
				
				setLable(subject_index,jsonData[p][j].infoSubject);
				marksMaps.remove(subject_index);
				marksMaps.remove(content_index);
			}else {//没有就放到其他类型下面
				if(jsonData[p][j].formContent !== ""){
					setLable(other_info_content,jsonData[p][j].formContent);
				}else {
					if(jsonData[p][j].infoFolder){
						if(other_info_content){
							ocxObj.FuncExtModule.WebSetMsgByName("bookMarkName", other_info_content);
						}
						if(jsonData[p][j].infoFolder){
							ocxObj.FuncExtModule.WebSetMsgByName("fileUrl", jsonData[p][j].infoFolder);
						}	
						ret=ocxObj.FuncExtModule.WebInsertFile();//插入文件操作
					}
				}
				
				if(marksMaps.containsKey(other_info_reporter)){
					setLable(other_info_reporter,jsonData[p][j].reporter);
					marksMaps.remove(other_info_reporter);
				}
				
				if(marksMaps.containsKey(other_info_reportDept)){
					setLable(other_info_reportDept,jsonData[p][j].reportDept);
					marksMaps.remove(other_info_reportDept);
				}
				
				if(marksMaps.containsKey(other_info_reportUnit)){
					setLable(other_info_reportUnit,jsonData[p][j].reportUnit);
					marksMaps.remove(other_info_reportUnit);
				}
				
				setLable(other_info_subject,jsonData[p][j].infoSubject);
				marksMaps.remove(other_info_subject);
				marksMaps.remove(other_info_content);
				other_index ++;
				
				//本次循环更新其他书签名称
				other_info_subject = "other_info"+other_index+"_subject";
				other_info_content = "other_info"+other_index+"_content";
				other_info_reporter = "other_info"+other_index+"_reporter";
				other_info_reportDept = "other_info"+other_index+"_reportDept";
				other_info_reportUnit = "other_info"+other_index+"_reportUnit";
			}
		}
		
		if(!isNormal && marksMaps.containsKey(other_category)){//没有就放到其他类型下面
			for(var k=0; k<jsonData[p].length; k++){
				other_info_subject = "other_info"+(other_index)+"_subject";
				other_info_content = "other_info"+(other_index)+"_content";
				other_info_reporter = "other_info"+other_index+"_reporter";
				other_info_reportDept = "other_info"+other_index+"_reportDept";
				other_info_reportUnit = "other_info"+other_index+"_reportUnit";
				
				if(jsonData[p][k].formContent !== ""){
					setLable(other_info_content,jsonData[p][k].formContent);
				}else {
					if(jsonData[p][k].infoFolder){
					  if(other_info_content){
							ocxObj.FuncExtModule.WebSetMsgByName("bookMarkName", other_info_content);
					  }
						if(jsonData[p][k].infoFolder){
							ocxObj.FuncExtModule.WebSetMsgByName("fileUrl", jsonData[p][k].infoFolder);
					  }
						ret=ocxObj.FuncExtModule.WebInsertFile();//插入文件操作
					}
				}
				
				if(marksMaps.containsKey(other_info_reporter)){
					setLable(other_info_reporter,jsonData[p][k].reporter);
					marksMaps.remove(other_info_reporter);
				}
				
				if(marksMaps.containsKey(other_info_reportDept)){
					setLable(other_info_reportDept,jsonData[p][k].reportDept);
					marksMaps.remove(other_info_reportDept);
				}
				
				if(marksMaps.containsKey(other_info_reportUnit)){
					setLable(other_info_reportUnit,jsonData[p][k].reportUnit);
					marksMaps.remove(other_info_reportUnit);
				}
				
				setLable(other_info_subject,jsonData[p][k].infoSubject);
				marksMaps.remove(other_info_subject);
				marksMaps.remove(other_info_content);
				other_index ++;
			}
			
		}
		index ++;
	}
}
//打开本地文件按钮点击事项回调函数
HandWrite.prototype.openFileCallBack=function(callBackFunction){
	if(typeof(callBackFunction)=="function"){
		loadFileCallBack=callBackFunction;
	}
}
/**
 * 设置授权信息
 * @param ocxObj
 * @return
 */
function setCopyRight(){
	try {
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		if(ocxObj){
			if(parent.___OfficeLicese && parent.___OfficeLicese != ""){
				ocxObj.CopyRight = parent.___OfficeLicese;
			}
		}
	}
	catch (e) {
	}
}

/**
 * 读取文件名，如果文件名不存在，则使用id
 */
function getOcxFileName(fileName,fileId){
	if(typeof(fileName)!="undefined" && fileName!=null){
		return fileName;
	}else{
		return fileId;
	}
}


/**
*加载office页面
*/
HandWrite.prototype.loadOffice=function (){
	
	this.transAttribute(this.canEdit,this.canCopy,this.hasTrail);
	if(!this.isLoadOfficeImmediate){
		this.isLoadOfficeFile = false;
		parent.OfficeUtils.hideOfficeFrameDiv();
		return true;
	}
  if(!this.isHandWriteRef())return;
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	//判断office插件是否存在
	if(!ocxObj){
		return false;
	}
	//只读情况下，把office2007的工具栏最小话
	ocxObj.FileType = "." + this.fileType;
	if(this.editType=="0,0" || this.editType=="4,0"){
		var gRibbonStatus = ocxObj.Office2007Ribbon;     // -1表示没有安装Office2007,4表示设置功能区最小化,0设置功能区最大化
  		if (gRibbonStatus!=-1){   //OFFICE2007存在最大化
    		ocxObj.Office2007Ribbon=4;
   		}
	}	
	WebOfficeInsertMenuDisable(ocxObj,false);
	this._loadOffice(ocxObj,this.params);
	//隐藏花脸
	if(this.isShowHualian){
		for(i=201;i<206;i++){
			ocxObj.DisableMenu(getVerMenuName(i));
		}
	}
}
//打开office正文
HandWrite.prototype._loadOffice=function(){
	var ocxObj = document.getElementById("WebOffice2015");
	//规则：非中文繁体、简体情况下皆显示未英文
	var jsLocalLanguage = "EN";
	if(this.currentLanguage == "zh-cn" || this.currentLanguage == "zh_CN"){//中文简体
		jsLocalLanguage = "CH";
	}else if(this.currentLanguage == "zh-tw" || this.currentLanguage == "zh_TW"){//中文繁体
		jsLocalLanguage = "TW";
	}
	//chrome下弹出窗口时Office控件需要隐藏
	if(setOfficeFlag){
		ocxObj.setAttribute("isDialog",this.isDialog);
		//非在线编辑时才设置控件的对象
		if(!parent.editOnline){
			  var flag = handWriteObj.needSave?false:true;
	    	  setOfficeFlag(flag,ocxObj);
	    }
	}
	try{
		ocxObj.Style.ShowOpenProgress = true;
		ocxObj.Style.ShowFullSize = false;//显示右上角的全屏按钮
		ocxObj.FullWindowStyle=1;
		ocxObj = ocxObj.FuncExtModule;
		setSession();
		var fileType = this.fileType;
		ocxObj.ShowToolBar = "1";
		ocxObj.WebUrl = this.webRoot +"/officeservlet";
		ocxObj.RecordID = this.fileId;
		
		var loadFileId = (this.originalFileId == null|| this.originalFileId=="")? this.fileId : this.originalFileId;
		var __fileType = getOfficeExtension(fileType,loadFileId);
		fileType = __fileType;
		
		ocxObj.FileType = "." + fileType;
		ocxObj.EditType = this.editType;
		ocxObj.ChangeSize=true;   //设置为允许全屏时修改全屏窗口的大小
		ocxObj.Language = jsLocalLanguage;
		if(fileType.indexOf(".")!= -1){
			ocxObj.FileType = fileType;
		    ocxObj.FileName = getOcxFileName(this.fileName,this.fileId) + fileType.substring(1);
		}else{
			ocxObj.FileType ="."+ fileType;
			ocxObj.FileName = getOcxFileName(this.fileName,this.fileId) + fileType;
		}
		ocxObj.UserName = this.currentUserName;
		ocxObj.Template = "";
		if(this.createDate){
			ocxObj.WebSetMsgByName("CREATEDATE", this.createDate);
		}		
		
		ocxObj.WebSetMsgByName("CATEGORY", "1");
		if(this.needSave){
			ocxObj.WebSetMsgByName("needSave", this.needSave);
		}
		if(this.originalNeedClone){
			ocxObj.WebSetMsgByName("originalNeedClone", this.originalNeedClone);
		}
		if(this.originalFileId){
			ocxObj.WebSetMsgByName("originalFileId", this.originalFileId);
		}
		if(this.originalCreateDate){
			ocxObj.WebSetMsgByName("originalCreateDate", this.originalCreateDate);
		}
		if(this.needCloneFile){
			ocxObj.WebSetMsgByName("needCloneFile", this.needCloneFile);
		}
		if(this.needReadFile){
			ocxObj.WebSetMsgByName("needReadFile", this.needReadFile);
		}
		if(this.affairMemberId){
			ocxObj.WebSetMsgByName("affairMemberId",this.affairMemberId);
		}	
		if(this.affairMemberName){
			ocxObj.WebSetMsgByName("affairMemberName",this.affairMemberName);
		}
		if(this.isReadNewFile) {
			ocxObj.WebSetMsgByName("isReadNewFile", this.isReadNewFile);
		}
		if(!initOcxMenued){
			this.initOcxMenu(ocxObj);//初始化控件菜单
		}
		
	    if(!checkFileSize(this.officeFileRealSize,this.officeOcxUploadMax, ocxObj)){
	    	return false;
	    }
	  //通过自定义属性设置当前登录用户的id
		ocxObj.ExtParam = this.userId;
	    WebSetRibbonUIXML(ocxObj);
	    
	    //这个是设置是否允许保存成兼容模式的,如果设置成true，就全部保存成03格式的了，设置成false07格式的才能保存成07的，维持文档本身的格式
	    ocxObj.Compatible = false;
	    //这个是设置wps和word是否能互相保存的，如果设置成true，那么wps能保持word的正文，word两种正文都能保持
	    ocxObj.MixedSave = true;
	    //本地安装的是永中office的时候，wps正文要置为只读状态
		var isYozoOffice = ocxObj.WebApplication(".eio");
		if((fileType == ".wps" || fileType == ".et" || fileType == "wps" || fileType == "et") && isYozoOffice && ocxObj.EditType != "0,0" && ocxObj.EditType != "4,0"){
			//本地安装的是永中Office，不支持对wps正文的编辑，系统自动将正文置为只读状态!
			alert(getOfficeLanguage("alert_YozoModifyWps"));
			ocxObj.EditType = "0,0";
		}
		ocxObj.WebSetMsgByName("currentUserId",this.userId);
		try{
			ocxObj.WebCreateProcess();
		}catch(e){}

		this.adjustMenuBeforeOpen(ocxObj);	
		this.setOcxMenuStateBeforeOpen(ocxObj);//根据控件的模式，使用的模块设在菜单的状态

		ocxObj.WebSetMsgByName("privateId",this.privateId);
		ocxObj.WebSetMsgByName("formDataId",this.formDataId);
		

	    var status1 = ocxObj.WebOpen();
	    //默认勾选 【不管是否登陆到OFFICE都始终使用用户名】 只针对word生效
	    if (fileType == "doc" || fileType == "docx" || fileType == ".doc" || fileType == ".docx") {
	    	try{
				ocxObj.WebObject.Application.Options.UseLocalUserInfo = true;
			}catch(e){}
		}
	    if(this.isFullSize){
			handWriteObj.FullSize();
		}
	    var hasSign=ocxObj.SignatureCount(true)>0;
  		if(hasSign){
			ocxObj.EditType="0,0";
  		}
	    
	    this.loadOfficeSuccess = status1;
		//设置正文更新时间
		lastUpdateTime=ocxObj.WebGetMsgByName("OfficeUpdateTime");
		this.adjustMenuAfterOpen(ocxObj);	
		this.setOcxMenuStateAfterOpen(ocxObj);//根据控件的模式，使用的模块设在菜单的状态			
		
		setSignatureColor(ocxObj);
		this.page_OcxState="complete";
		this.isLoadOfficeFile=true;	
		setOfficeShowPicture(ocxObj,true);
		
		if(this.initOfficeSucessCallback!=null){
			this.initOfficeSucessCallback();
		}
		return status1;
	}
	catch(e){
	/*	if((e.number & 0xFFFF)==438){
			alert(getOfficeLanguage("alert_err_UpdateOcx"));
		}
		else{
			alert(""+(e.number & 0xFFFF) + "\n\n" + e.description);
		}	 */ 
	}

}

function getOfficeLanguage(keys){
  var str=parent.OfficeUtils.getOfficeLanguage(keys,arguments);
  return str;
}
/**
*按钮绑定事件
*/
HandWrite.prototype.attachEvent = function (){
  var ocxObj=document.getElementById("WebOffice2015").FuncExtModule;
  if(ocxObj){
        var callBackFun = this.OnMenuClick;
        var handObj = this;
        if(typeof(ocxObj.attachEvent)!="undefined"){
        	ocxObj.attachEvent("OnMenuClick", 
        			function(vIndex, vCaption){
        		OnMenuClick(vIndex, vCaption, handObj);
        	}
        	);
        }else{
        	ocxObj.addEventListener("OnMenuClick", 
        			function(vIndex, vCaption){
        		OnMenuClick(vIndex, vCaption, handObj);
        	}
        	);
        	
        }
  }
}
HandWrite.prototype.getOcxState=function(){
	if(!this.isHandWriteRef(false)){
		return "";
	}
	return this.page_OcxState;
}

HandWrite.prototype.getFileSize=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	return ocxObj.WebGetMsgByName("fileSize");
}
HandWrite.prototype.repairContent=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	var hasSign= ocxObj.SignatureCount(true)>0 || this.HasSpecialSignature(ocxObj);
	if(hasSign){
		ocxObj.alert(getOfficeLanguage("alert_info_canNotRepairContent"));
		return;
	}
	var backFileName = ocxObj.WebGetMsgByName("backFileName");
	 if(ocxObj.confirm(getOfficeLanguage("alert_repairContent"))==false){
     	return;
     }
	 this.loadBackFile = true;
	ocxObj.WebSetMsgByName("backFileName",backFileName);
	ocxObj.WebSetMsgByName("loadBack","true");
	this._loadOffice();
	//隐藏痕迹
	ocxObj.WebSetRevision(false,isTrack(),false,true);
}



HandWrite.prototype.enableRepairContent=function(ocxObj){
	var hasSign= ocxObj.SignatureCount(true)<=0 &&  !this.HasSpecialSignature(ocxObj);
    if(ocxObj.WebGetMsgByName("backFileName")!="" && hasSign){
      	  ocxObj.EnableMenu(getOfficeLanguage("menu_RepairContent"));
    }else{
    	  ocxObj.DisableMenu(getOfficeLanguage("menu_RepairContent"));
    }
}

//作用：套用模版定稿
function WebApplyRedHead(mObject,flag){
	try{
		if(!mObject.ActiveDocument.Bookmarks.Exists("Content")){
			mObject.FuncExtModule.WebSetMsgByName("CUROPERATE","");
			return;
		}
		/***获取模板正文格式****/
		var mSelection = mObject.ActiveDocument.Application.Selection;
		mSelection.GoTo(-1,0,0,"Content");			//跳转到正文书签位置
		var font =mSelection.Font.Name;				// 获取正文字体
		var fontSize=mSelection.Font.Size;			// 获取正文字体大小
		var fontColor=mSelection.Font.Color;		// 获取正文字体颜色
		var fontSpacing=mSelection.Font.Spacing;	// 获取正文字体间距
		var fontBold=mSelection.Font.Bold;				// 获取正文字体加粗
		var firstLineIndent=mSelection.ParagraphFormat.FirstLineIndent;	//首行缩进
		var characterUnitFirstLineIndent=mSelection.ParagraphFormat.CharacterUnitFirstLineIndent;//一级标题缩进
		var lineSpacingRule=mSelection.ParagraphFormat.LineSpacingRule;//行间距
		
		if (mObject.FuncExtModule.WebInsertFile()){                   //填充公文正文   交互OfficeServer的OPTION="INSERTFILE"
			mObject.FuncExtModule.WebSetMsgByName("CUROPERATE","");
			/***设置模板正文格式****/
			var browser = new Browser();
			var BookmarkStart = null;
			var BookmarkEnd = null;
			if(browser.isChrome){
				BookmarkStart =  mObject.ActiveDocument.Bookmarks.Item("ContentStart").Start;
				BookmarkEnd = mObject.ActiveDocument.Bookmarks.Item("ContentEnd").Start;
			}else if(browser.isMSIE){
				BookmarkStart = mObject.ActiveDocument.Bookmarks("ContentStart").Start;
				BookmarkEnd = mObject.ActiveDocument.Bookmarks("ContentEnd").End;
			}
			mSelection.SetRange(BookmarkStart, BookmarkEnd);                //选择正文信息
			mSelection.Font.Name = font;				// 获取正文字体
			mSelection.Font.Size = fontSize;			// 获取正文字体大小
			mSelection.Font.Color = fontColor;		// 获取正文字体颜色
			mSelection.Font.Spacing=fontSpacing;	// 获取正文字体间距
			mSelection.Font.Bold=fontBold;			// 获取正文字体加粗
			mSelection.ParagraphFormat.FirstLineIndent=firstLineIndent;//首行缩进
			mSelection.ParagraphFormat.CharacterUnitFirstLineIndent=characterUnitFirstLineIndent;//一级标题缩进
			mSelection.ParagraphFormat.LineSpacingRule=lineSpacingRule;//行间距
			mSelection.move();
			/******/
			mObject.Active(true);
		}
	}catch(e){}
}
function setFileName(ocxObj){
	var _oldfileName = ocxObj.fileName;
	var _fileId = parent.OfficeUtils.getOcxFileName(ocxObj.RecordID);
	if(ocxObj.FileType.indexOf(".") != -1){
		ocxObj.fileName=_fileId+ocxObj.FileType.substring(1);
	}else{
		ocxObj.fileName=_fileId+ocxObj.FileType;
	}
	return _oldfileName;
}
HandWrite.prototype.formTaohong=function(params){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	for(var i=0;i<params.length;i++){
		var type = params[i].inputType;
		var book = params[i].target;
		var val = params[i].value;
		if(type == "image" || type == "handwrite" || type == "barcode"){
			ocxObj.WebSetMsgByName("inputType",type);
			if(type == "image" && val){
				var valArray = val.split("_");
				val = valArray[0];
				if(valArray[1] && valArray[1].length>=10){//处理一下时间
					ocxObj.WebSetMsgByName("createDate",valArray[1].substring(0,10));
				}
			}
			try{//OA-125385
				ocxObj.WebInsertImageEx(book,val,true,3,true);
			}catch(e){//兼容老版本
				ocxObj.WebInsertImageEx(book,val,true,3);
			}
		}else if(type == "flowdealoption"){
			if(val && val.indexOf("@signet@") != -1){
				var str = val.match(/@signet@(\S*)@signet@/);
				if(str && str.length > 0){
					val = val.replace(str[0],"");
				}
			}
			ocxObj.WebSetBookmarks(book,val);
		}else {
			if(typeof(val) == "object"){
				var cell;
				var tdObj = document.getElementById("WebOffice2015");
				tdObj.editType = "1,0";
				var webObject = tdObj.Activedocument;
				var pageS = webObject.PageSetup;
				pageS.PageWidth = webObject.Application.CentimetersToPoints(21); //设置纸张宽度
				pageS.PageHeight = webObject.Application.CentimetersToPoints(29.7); //设置纸张高度
				for(var index = 0; index < val.length;index++){
					var cellVal = (val[index] == null ? "" : val[index]);
					//书签是否存在
					if (webObject.BookMarks.Exists(book) == true) {
						//书签定位
						cell = webObject.Bookmarks.Item(book);
						if(params[i].subList[index].newRow){
							var currentRows = cell.Range.Tables.Item(1).Rows.Count;
							if(index == 0 &&
								 currentRows> 3){
								for(var j=3; j < currentRows; j++){
									cell.Range.Tables.Item(1).Rows.Item(3).Delete();
								}
							}
							cell.Range.Rows.Add(cell.Range.Rows.Last);
						}
						cell.Range.Tables.Item(1).Cell(params[i].subList[index].row, params[i].subList[index].column).Range.Text = cellVal;
					}
				}
			} else {
				ocxObj.WebSetBookmarks(book,val);
			}
		}
	}
	if(params.length > 0){
		ocxObj.WebSetMsgByName("hasFormTaoHong", "1");
	}
}
function OnFullSizeBefore(val){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	if(val==false){//关闭office窗口
		ocxObj.WindowStatus=1;
		ocxObj.EnableMenu(getOfficeLanguage("menu_FullScreenMode"));
        ocxObj.DisableMenu(getOfficeLanguage("menu_SaveExit"));
        
		if(!this.isSave){
			 if(handWriteObj.callback!=null){
		    	  saveSucess = handWriteObj.callback(this);
			 }
			if(handWriteObj.needSave){
				handWriteObj.saveOffice();
			}
		}else{
			this.isSave=false;
		}
		if(handWriteObj.loadOfficeSuccess){
				
			if(handWriteObj.initOfficeCloseCallback != null 
				&& typeof(handWriteObj.initOfficeCloseCallback)!="undefined"){
						
				var fileSize = ocxObj.WebGetMsgByName("fileSize");
				var saveDate = ocxObj.WebGetMsgByName("saveDate");
				handWriteObj.initOfficeCloseCallback(fileSize,saveDate);
			}
		}else{
			if(handWriteObj.initOfficeErrorCallback != null && typeof(handWriteObj.initOfficeErrorCallback)!="undefined"){
				handWriteObj.initOfficeErrorCallback();
			}
		}
	}else{
		ocxObj.DisableMenu(getOfficeLanguage("menu_FullScreenMode"));
        ocxObj.EnableMenu(getOfficeLanguage("menu_SaveExit"));
	}
}

HandWrite.prototype.needUpdateOcx=function(){
	return handWriteObj.updateOcx;
}
function isExcelFileType(type){
	if(type == "xls" || type == "xlsx" || type == ".xls" || type == ".xlsx"){
		return true;
	}else{
		return false;
	}
}
function isWordFileType(type){
	if(type == "doc" || type == "docx" || type == ".doc" || type == ".docx"){
		return true;
	}else{
		return false;
	}
}
//获取正文的状态
HandWrite.prototype.getShowType=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	this.checkOpenState();//必须先打开，才能获取到正文状态
    return ocxObj.ShowType;
}

//新公文 刷新Office中文中的Label.
HandWrite.prototype.refreshEdocOfficeLable=function(sendForm,extendArray){
	//刷新套红后正文中的标签。需要先将OFFICE控件设置为可编辑模式。
	if(sendForm){
		var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
		if(ocxObj.EditType=="0,0"||ocxObj.EditType=="4,0"){
			var srcEditType=ocxObj.EditType;
			ocxObj.EditType="1,0";
			setAllLable(sendForm,"edoc",extendArray);
			ocxObj.EditType=srcEditType;
		}else{
			setAllLable(sendForm,"edoc",extendArray);
		}
	}
}

/**
 * 打开office正文页签时，设置签章可用
 */
HandWrite.prototype.updateSignatureState = function(){
	  var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	  if(this.curMenuID != 200){
		  return;
	  }
	  //如果上次编辑为手写批注模式最新为手写，当前不是清稿模式，不能盖章
	  //                          最新为文字（上次编辑为文字或者清稿），当前为手写批注模式，不允许盖章
	  if((ocxObj.LastType==2 && ocxObj.ShowType!=0) || ((ocxObj.LastType==0 || ocxObj.LastType==1) && ocxObj.ShowType==2))
	  {
	    return;
	  }
	  //检查当前显示模式，如果是手写批注模式，切换到文字模式
	  if(ocxObj.ShowType==2){ocxObj.ShowType=1;}
}

/**
 * 公文套红更新书签值
 */
HandWrite.prototype.refreshEdocTaohong = function(dataForm,docMarkVal){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	ocxObj.EditType="1,0";
	isAlertProtectFile = false;//正文盖章后，套红时，弹出提示语“不允许您编辑此内容，因为它受保护”，这个变量用于是否弹出这个提示语
	var allData = dataForm.find("[id^=field]");
	for(var i=0;i<allData.length;i++){
		var oneData = allData[i];
		var label = oneData.getAttribute("mappingField");
		var dataValue = oneData.getAttribute("text");
		if(undefined == dataValue || null == dataValue || "" == dataValue){
			dataValue = oneData.innerText;
		}
		if(undefined == dataValue || null == dataValue || "" == dataValue){
			dataValue = oneData.value;
		}
		//公文模板中绑定套红模板，拟文时提示是否自动更新文单中书签内容，点取消，只更新一部分书签
		if(undefined == dataValue || null == dataValue || "" == dataValue){
			var child = oneData.childNodes;
			if(child!=null&&child.length>0){
				var inputNode = child.item(0);
				var tagN = inputNode.nodeName;
				if(tagN !="undefined" && (tagN == "INPUT" || tagN == "inputs")){
					dataValue = inputNode.value;
				}
			}
		}
		var fieldVal = oneData.getAttribute("fieldVal");
		var comp = oneData.getAttribute("comp");
		var editData = oneData.children.item(0);
		if(undefined!=fieldVal){
			fieldVal = eval('(' + fieldVal + ')');
		}
		var tagN = oneData.nodeName;
		if(tagN !="undefined" && (tagN == "INPUT" || tagN == "inputs")){//如果是编辑状态的意见
			var parentData = oneData.parentNode.parentNode;
			if("undefined"!=parentData&&(parentData.nodeName=="SPAN"||parentData.nodeName=="span")){
				var f = parentData.getAttribute("fieldVal");
				if("undefined"!=f&&null!=f){
					f = eval('('+f+')');
					if(f.inputType=='edocflowdealoption'){
						continue;
					}
				}
			}
		}
		var keys = ["请选择机构代字","請選擇機構代字","请选择内部文号","請選擇內部文號","please choose innser mark","请选择公文文号","請選擇公文文號","please choose mark"];
		if(tagN !="undefined" && (tagN == "SELECT" || tagN == "select")){
			var index = oneData.selectedIndex;
			dataValue = oneData.options[index].text;
			if(label == 'serial_no'){ //当内部文号为空时不设置书签
				if(inArray(dataValue,keys)>-1){
					dataValue = "";
				}else{
					if(typeof(index)!="undefined" && undefined != oneData.options[index] && null != oneData.options[index]) {
						dataValue = oneData.options[index].value;
						if(dataValue && dataValue != ""){
							var a = dataValue.split("|");
							if(a.length > 1){
								dataValue = a[1];
							} else {
								dataValue = oneData.options[index].value;
							}
						}
					}
				}
			}
			if(label == 'doc_mark'){//当来文文号为空时不设置书签
				if(inArray(dataValue,keys)>-1){
					dataValue = "";
				}else{
					if(typeof(index)!="undefined" && undefined != oneData.options[index] && null != oneData.options[index]) {
						dataValue = oneData.options[index].value;
						if(dataValue && dataValue != ""){
							var a = dataValue.split("|");
							if(a.length > 1){
								dataValue = a[1];
							} else {
								dataValue = oneData.options[index].value;
							}
						}
					}
				}
				if(typeof(docMarkVal)!='undefined' && null!=docMarkVal){
					dataValue=docMarkVal;
				}
			}
		}
		if(undefined!=fieldVal){
			if(undefined==label){
				label = fieldVal.name;
			}
			if(undefined!=editData){
				var tagName = editData.nodeName;
				if(tagName !="undefined" && (tagName == "SELECT" || tagName == "select")){
					var index = editData.selectedIndex;
					if(index) {
						dataValue = editData.options[index].text;
					}
				}
				if(fieldVal.inputType=='edocflowdealoption'&&tagName !="undefined" && (tagName == "DIV" || tagName == "div")){
					var a = editData.innerText;
					a   =   a.replace(/\s+/g,"");
					if(a==""){
						dataValue="";
					}
				}
				if(fieldVal.fieldType=='TIMESTAMP'&&tagName !="undefined" && (tagName == "INPUT" || tagName == "input")){
					dataValue = editData.getAttribute("value");
				}
				if((fieldVal.inputType=='member'||fieldVal.inputType=='account'||fieldVal.inputType=='department'||fieldVal.inputType=='post')&&tagName !="undefined" && (tagName == "INPUT" || tagName == "input")){

					dataValue = editData.getAttribute("title");
				}
				if(fieldVal.inputType=='edocDocMark'||fieldVal.inputType=='edocInnerMark'){
					editData = oneData.children.item(0);
					if(undefined != editData && null != editData){
						if(undefined!=editData&&(tagName=="SELECT"||tagName=='select')){
							var index = editData.selectedIndex;
							if(index) {
								dataValue = editData.options[index].text;
							}
						}
					}
				}
			}
		}
		//}
		if(undefined != dataValue && null != dataValue && label != null){
			try{setLable(label,dataValue);}catch(e){alert(e);}
		}
	}
	
	//意见套红
	taohongOpinionOld("edoc");
}

function inArray(elem, arr, i) {
	var len = arr.length;
	i = i ? i < 0 ? Math.max(0, len + i) : i : 0;
	for (; i < len; i++) {
		// Skip accessing in sparse arrays
		if (i in arr && arr[i] === elem) {
			return i;
		}
	}
	return -1;
}

HandWrite.prototype.loadNewFile=function(param){
	this.fileId=param.newFileId;
	this.fileType = param.fileType;
	if(param.isEdit){
		this.editType="0,0";
	}else{
		this.editType="2,1";
	}
	this.needReadFile = true;
	this.isReadNewFile = true;
	this._loadOffice();
}
HandWrite.prototype.setExtendParams=function(param){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	for(var key in param ){
		this.extendParams[key] = param[key];
	}
}
HandWrite.prototype.delComments=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	var mCommentsCount = ocxObj.WebObject.Comments.Count;
	for (var j=mCommentsCount; j>=1; j--){
		ocxObj.WebObject.Comments.Item(j).Range.Select();
		ocxObj.WebObject.Application.Selection.Comments.Item(1).Delete();
	}
	ocxObj.WebObject.Application.ActiveWindow.View.Type = 3;
}
HandWrite.prototype.hasComment=function(){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	var mCount = ocxObj.WebObject.Comments.Count;
	if(mCount>0){
		return true;
	}
	return false;
}

//作用：设置活动文档对象：360签章对象
HandWrite.prototype.setActiveDocument=function(){
	try{
		var varObj = null;
		var ocxObj = document.getElementById("WebOffice2015")
		if(ocxObj != null && ocxObj.ActiveDocument != null)
		{
			var  varApp = ocxObj.ActiveDocument.Application;
			var varComAddIns = null;
			var varAddin = null;
			var varOffice360Addin = "iSignatureOffice360.AddIn";
			var varOffice360Obj = null;
			if(varApp)
			{
				varComAddIns = varApp.COMAddIns;
			}	
			if(varComAddIns)
			{
				for(var i = 1;i <=varComAddIns.Count;i++)
				{
					varAddin = varComAddIns.Item(i);
					if(varOffice360Addin == varAddin.ProgId)
					{
						varOffice360Obj = varAddin.Object;
						break;
					}
				}
				if(varOffice360Obj)
				{
					try
					  {
						varObj = varOffice360Obj.GetInterfaceForWeb("iSignatureOffice360.API");
					  }
					  catch(err)
					  {
						  txt="There was an error on this page.\n\n";
						  txt+="Error description: " + err.message + "\n\n";
						  txt+="Click OK to continue.\n\n";
						  alert(txt);
					  }				
				}
			}
		}
		return varObj;
	}catch(e){}
}

//隐藏或者显示控件 0:隐藏，1:显示
HandWrite.prototype.hideOrShowOcx=function(hideOrShow){
	try{
		var ocxObj = document.getElementById("WebOffice2015")
		if(ocxObj != null ){
			var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;
			if(isChrome){
				ocxObj.HidePlugin(hideOrShow);
			}else{
				ocxObj.Hide(hideOrShow);
			}
		}
	}catch(e){}
}

//隐藏显示360签章
HandWrite.prototype.ActionUI_Update=function(blShow){ 
	try{
		var SignatureAPI360 = this.setActiveDocument();
		SignatureAPI360.ActionButtonShow(0,blShow);
		SignatureAPI360.ActionButtonShow(1,blShow);
		SignatureAPI360.ActionButtonShow(2,blShow);
		SignatureAPI360.ActionButtonShow(5,blShow);
		SignatureAPI360.ActionButtonShow(6,blShow);
		SignatureAPI360.ActionButtonShow(8,blShow);
		SignatureAPI360.ActionButtonUpdate();
	}catch(e){}
}
//金格插件中确认弹窗方法
HandWrite.prototype.confirm=function(confirmText){
	var ocxObj = document.getElementById("WebOffice2015").FuncExtModule;
	return ocxObj.confirm(confirmText);
}

//用正则表达式将前后空格
// 用空字符串替代。
var lrtrim = function(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
}
function setSession(){
	var isChrome = navigator.userAgent.toLowerCase().match(/chrome/) != null;
	var ocxObj = document.getElementById("WebOffice2015");
	if(isChrome && ocxObj){
		ocxObj.INetSetCookieEx(handWriteObj.webRoot +"/officeservlet", getSession());
	}
}
function getSession(){
	var requestCaller = new XMLHttpRequestCaller(this, "ajaxHandWriteManager", "ajaxGetSession",false);
	var ds = requestCaller.serviceRequest();
	
	return ds;
}
